]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
compal-laptop: Check return value of power_supply_register
authorKrzysztof Kozlowski <k.kozlowski@samsung.com>
Thu, 12 Mar 2015 07:44:00 +0000 (08:44 +0100)
committerJiri Slaby <jslaby@suse.cz>
Mon, 4 May 2015 09:49:50 +0000 (11:49 +0200)
commit15b684c9fb5012c63f46bc9a1523c8ad8b786a50
tree843add5bca5f87dea2adc0aef2b04a9cc177ec15
parent1467541ff04b7e4d6f91bc7fe5b447499a53d840
compal-laptop: Check return value of power_supply_register

commit 1915a718b1872edffcb13e5436a9f7302d3d36f0 upstream.

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.

Fix this by checking return status of power_supply_register() call. In
case of failure, clean up sysfs entries and fail the probe.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Fixes: 9be0fcb5ed46 ("compal-laptop: add JHL90, battery & hwmon interface")
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz> [backport to 3.12]
drivers/platform/x86/compal-laptop.c