Skip to content

Commit

Permalink
backlight: convert platform_lcd to devm_kzalloc()
Browse files Browse the repository at this point in the history
Saves some error handling code and eliminates a class of leaks.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Mark Brown authored and Linus Torvalds committed Jan 11, 2012
1 parent 6665576 commit 48e78e8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions drivers/video/backlight/platform_lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ static int __devinit platform_lcd_probe(struct platform_device *pdev)
return -EINVAL;
}

plcd = kzalloc(sizeof(struct platform_lcd), GFP_KERNEL);
plcd = devm_kzalloc(&pdev->dev, sizeof(struct platform_lcd),
GFP_KERNEL);
if (!plcd) {
dev_err(dev, "no memory for state\n");
return -ENOMEM;
Expand All @@ -98,16 +99,15 @@ static int __devinit platform_lcd_probe(struct platform_device *pdev)
if (IS_ERR(plcd->lcd)) {
dev_err(dev, "cannot register lcd device\n");
err = PTR_ERR(plcd->lcd);
goto err_mem;
goto err;
}

platform_set_drvdata(pdev, plcd);
platform_lcd_set_power(plcd->lcd, FB_BLANK_NORMAL);

return 0;

err_mem:
kfree(plcd);
err:
return err;
}

Expand All @@ -116,7 +116,6 @@ static int __devexit platform_lcd_remove(struct platform_device *pdev)
struct platform_lcd *plcd = platform_get_drvdata(pdev);

lcd_device_unregister(plcd->lcd);
kfree(plcd);

return 0;
}
Expand Down

0 comments on commit 48e78e8

Please sign in to comment.