[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-id: <1427124891-30540-1-git-send-email-k.kozlowski@samsung.com>
Date: Mon, 23 Mar 2015 16:34:51 +0100
From: Krzysztof Kozlowski <k.kozlowski@...sung.com>
To: Jiri Kosina <jkosina@...e.cz>, linux-input@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org
Cc: Sebastian Reichel <sre@...nel.org>,
Dmitry Eremin-Solenikov <dbaryshkov@...il.com>,
David Woodhouse <dwmw2@...radead.org>,
Dan Carpenter <dan.carpenter@...cle.com>,
Krzysztof Kozlowski <k.kozlowski@...sung.com>
Subject: [PATCH] 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@...sung.com>
Reported-by: Dan Carpenter <dan.carpenter@...cle.com>
---
The patch was prepared on top of next-20150323. It depends on changes in
power supply core (battery-2.6.git) so probably it should be applied to
the battery tree.
---
drivers/hid/hid-input.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index a70fa4d7f8f9..008e89bf6f3c 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;
}
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists