Skip to content

Commit

Permalink
power_supply: lp8788-charger: Fix leaked power supply on probe fail
Browse files Browse the repository at this point in the history
Driver forgot to unregister charger power supply if registering of
battery supply failed in probe(). In such case the memory associated
with power supply leaked.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Fixes: 98a2766 ("power_supply: Add new lp8788 charger driver")
Cc: <stable@vger.kernel.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
  • Loading branch information
Krzysztof Kozlowski authored and Sebastian Reichel committed Feb 25, 2015
1 parent a2c1d53 commit a7117f8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/power/lp8788-charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,10 @@ static int lp8788_psy_register(struct platform_device *pdev,
pchg->battery.num_properties = ARRAY_SIZE(lp8788_battery_prop);
pchg->battery.get_property = lp8788_battery_get_property;

if (power_supply_register(&pdev->dev, &pchg->battery))
if (power_supply_register(&pdev->dev, &pchg->battery)) {
power_supply_unregister(&pchg->charger);
return -EPERM;
}

return 0;
}
Expand Down

0 comments on commit a7117f8

Please sign in to comment.