OSDN Git Service

power_supply: twl4030_madc: Check return value of power_supply_register
authorKrzysztof Kozlowski <k.kozlowski@samsung.com>
Fri, 20 Feb 2015 13:32:22 +0000 (14:32 +0100)
committerSebastian Reichel <sre@kernel.org>
Wed, 25 Feb 2015 21:18:18 +0000 (22:18 +0100)
commit68c3ed6fa7e0d69529ced772d650ab128916a81d
tree1f6cf0b960169927fe87debf42ed2aac325bf5dc
parentcc6405667c633383cf9365731ad91e8a88d39b89
power_supply: twl4030_madc: Check return value of power_supply_register

The return value of power_supply_register() call was not checked and
even on error probe() function returned 0. If registering failed then
during unbind the driver tried to unregister power supply which was not
actually registered.

This could lead to memory corruption because power_supply_unregister()
unconditionally cleans up given power supply.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Fixes: da0a00ebc239 ("power: Add twl4030_madc battery driver.")
Cc: <stable@vger.kernel.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
drivers/power/twl4030_madc_battery.c