Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
leds: convert wm8350 driver to devm_kzalloc()
Browse files Browse the repository at this point in the history
Saves a small amount of code and systematically eliminates leaks.

Signed-off-by: Mark Brown <[email protected]>
Cc: Richard Purdie <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
broonie authored and torvalds committed Jan 11, 2012
1 parent 1713cb9 commit c957b61
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions drivers/leds/leds-wm8350.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ static int wm8350_led_probe(struct platform_device *pdev)
goto err_isink;
}

led = kzalloc(sizeof(*led), GFP_KERNEL);
led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL);
if (led == NULL) {
ret = -ENOMEM;
goto err_dcdc;
Expand Down Expand Up @@ -259,12 +259,10 @@ static int wm8350_led_probe(struct platform_device *pdev)

ret = led_classdev_register(&pdev->dev, &led->cdev);
if (ret < 0)
goto err_led;
goto err_dcdc;

return 0;

err_led:
kfree(led);
err_dcdc:
regulator_put(dcdc);
err_isink:
Expand All @@ -281,7 +279,6 @@ static int wm8350_led_remove(struct platform_device *pdev)
wm8350_led_disable(led);
regulator_put(led->dcdc);
regulator_put(led->isink);
kfree(led);
return 0;
}

Expand Down

0 comments on commit c957b61

Please sign in to comment.