Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drivers/video/backlight/adp5520_bl.c: use devm_ functions

The various devm_ functions allocate memory that is released when a driver
detaches. This patch uses these functions for data that is allocated in
the probe function of a platform device and is only freed in the remove
function.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Julia Lawall and committed by
Linus Torvalds
050ea48b ce969228

+1 -5
+1 -5
drivers/video/backlight/adp5520_bl.c
··· 289 289 struct adp5520_bl *data; 290 290 int ret = 0; 291 291 292 - data = kzalloc(sizeof(*data), GFP_KERNEL); 292 + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); 293 293 if (data == NULL) 294 294 return -ENOMEM; 295 295 ··· 298 298 299 299 if (data->pdata == NULL) { 300 300 dev_err(&pdev->dev, "missing platform data\n"); 301 - kfree(data); 302 301 return -ENODEV; 303 302 } 304 303 ··· 313 314 &adp5520_bl_ops, &props); 314 315 if (IS_ERR(bl)) { 315 316 dev_err(&pdev->dev, "failed to register backlight\n"); 316 - kfree(data); 317 317 return PTR_ERR(bl); 318 318 } 319 319 ··· 324 326 if (ret) { 325 327 dev_err(&pdev->dev, "failed to register sysfs\n"); 326 328 backlight_device_unregister(bl); 327 - kfree(data); 328 329 } 329 330 330 331 platform_set_drvdata(pdev, bl); ··· 345 348 &adp5520_bl_attr_group); 346 349 347 350 backlight_device_unregister(bl); 348 - kfree(data); 349 351 350 352 return 0; 351 353 }