OSDN Git Service

power_supply: ipaq_micro_battery: Check return values in probe
authorKrzysztof Kozlowski <k.kozlowski@samsung.com>
Fri, 20 Feb 2015 13:32:24 +0000 (14:32 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 6 May 2015 20:03:45 +0000 (22:03 +0200)
commit640e9bd83b3a3bc313eb0ade22effbab5c135a76
treeef14e7f2065b44273e5b15e8ef3b37858318e1e3
parenta8cb866f5168eaec313528f7059b0025b859cccf
power_supply: ipaq_micro_battery: Check return values in probe

commit a2c1d531854c4319610f1d83351213b47a633969 upstream.

The return values of create_singlethread_workqueue() and
power_supply_register() calls were not checked and even on error probe()
function returned 0.

1. If allocation of workqueue failed (returning NULL) then further
   accesses could lead to NULL pointer dereference. The
   queue_delayed_work() expects workqueue to be non-NULL.

2. If registration of power supply 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: 00a588f9d27f ("power: add driver for battery reading on iPaq h3xxx")
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/power/ipaq_micro_battery.c