]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commit
power_supply: 88pm860x_charger: Fix possible NULL pointer dereference and use of...
authorKrzysztof Kozlowski <k.kozlowski@samsung.com>
Fri, 20 Mar 2015 09:26:02 +0000 (10:26 +0100)
committerSebastian Reichel <sre@kernel.org>
Fri, 20 Mar 2015 11:46:04 +0000 (12:46 +0100)
commitc94a3d403299f64d2f91346ff64c4b95747c123c
tree427bc1796eced6e09db5914518dd13df5f996184
parentd3a6097b25e09751cba787b33eba26ab4df86215
power_supply: 88pm860x_charger: Fix possible NULL pointer dereference and use of initialized variable

Do not put reference to power supply in early exit paths of
pm860x_done_handler() because:
1. it is not yet initialized,
2. it is NULL.

This fixes possible NULL pointer dereference and following build
warning:
drivers/power/88pm860x_charger.c: In function ‘pm860x_done_handler’:
drivers/power/88pm860x_charger.c:516:18: warning: ‘psy’ may be used uninitialized in this function [-Wmaybe-uninitialized]

Additionally this puts the power supply reference before unlocking
mutex. This actually is not needed (there is no race here) but has
logical sense and makes the exit paths cleaner.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
drivers/power/88pm860x_charger.c