power_supply: lp8788-charger: Fix leaked power supply on probe fail
authorKrzysztof Kozlowski <k.kozlowski@samsung.com>
Fri, 20 Feb 2015 13:32:25 +0000 (14:32 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 6 May 2015 19:56:21 +0000 (21:56 +0200)
commit a7117f81e8391e035c49b3440792f7e6cea28173 upstream.

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: 98a276649358 ("power_supply: Add new lp8788 charger driver")
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/power/lp8788-charger.c

index ed49b50b220b3ed6541c5b6f82079e1d0373e8f7..72da2a6c22db953b1c9c95a84fc27a9007580891 100644 (file)
@@ -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;
 }