summaryrefslogtreecommitdiff
path: root/drivers/hid/hid-input.c
diff options
context:
space:
mode:
authorKrzysztof Kozlowski <k.kozlowski@samsung.com>2015-03-23 18:34:51 +0300
committerSebastian Reichel <sre@kernel.org>2015-03-24 15:38:16 +0300
commitfbea947c7d122f4704001fac2a96b617f767037a (patch)
tree3b5edfdd2c0d942317d88b3d90cacd9b8395dfda /drivers/hid/hid-input.c
parent8fb0885504cc029bd48877fa89ba91c33c0110b5 (diff)
downloadlinux-fbea947c7d122f4704001fac2a96b617f767037a.tar.xz
HID: input: Fix NULL pointer dereference when power_supply_register fails
Do not call power_supply_powers() if power_supply_register() failed earlier. This fixes possible NULL pointer dereference by power_supply_powers() in such case. Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/hid/hid-input.c')
-rw-r--r--drivers/hid/hid-input.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 5d5a8c42645f..32c2da49bd5b 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -452,10 +452,10 @@ static bool hidinput_setup_battery(struct hid_device *dev, unsigned report_type,
kfree(psy_desc->name);
kfree(psy_desc);
dev->battery = NULL;
+ } else {
+ power_supply_powers(dev->battery, &dev->dev);
}
- power_supply_powers(dev->battery, &dev->dev);
-
out:
return true;
}