diff options
author | Marcin Niestroj <m.niestroj@grinn-global.com> | 2016-06-14 09:29:24 -0400 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2016-06-16 09:54:11 -0400 |
commit | 362761299eea7dfc3a4870551de36e08758b9254 (patch) | |
tree | af1d16635b15c67c10d81d92234b386f528ad076 | |
parent | 5bc28b93a36e3cb3acc2870fb75cb6ffb182fece (diff) |
power_supply: tps65217-charger: Fix NULL deref during property export
This bug leads to:
[ 1.906411] Unable to handle kernel NULL pointer dereference at virtual address 0000000c
[ 1.914878] pgd = c0004000
[ 1.917786] [0000000c] *pgd=00000000
[ 1.921536] Internal error: Oops: 5 [#1] SMP ARM
[ 1.926357] Modules linked in:
[ 1.929556] CPU: 0 PID: 14 Comm: kworker/0:1 Not tainted 4.4.5 #18
[ 1.936006] Hardware name: Generic AM33XX (Flattened Device Tree)
[ 1.942383] Workqueue: events power_supply_changed_work
[ 1.947842] task: de2c41c0 ti: de2c8000 task.ti: de2c8000
[ 1.953483] PC is at tps65217_ac_get_property+0x14/0x28
[ 1.958937] LR is at tps65217_ac_get_property+0x10/0x28
Driver was trying to use drv_data in property get handler. However drv_data
was not set, so it caused NULL pointer dereference. This patch properly
sets drv_data during probe by power_supply_config parameter, so the
property get handler works as desired.
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Fixes: 3636859b280c ("power_supply: Add support for tps65217-charger")
Signed-off-by: Sebastian Reichel <sre@kernel.org>
-rw-r--r-- | drivers/power/tps65217_charger.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/power/tps65217_charger.c b/drivers/power/tps65217_charger.c index d9f56730c735..73dfae41def8 100644 --- a/drivers/power/tps65217_charger.c +++ b/drivers/power/tps65217_charger.c | |||
@@ -197,6 +197,7 @@ static int tps65217_charger_probe(struct platform_device *pdev) | |||
197 | { | 197 | { |
198 | struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent); | 198 | struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent); |
199 | struct tps65217_charger *charger; | 199 | struct tps65217_charger *charger; |
200 | struct power_supply_config cfg = {}; | ||
200 | int ret; | 201 | int ret; |
201 | 202 | ||
202 | dev_dbg(&pdev->dev, "%s\n", __func__); | 203 | dev_dbg(&pdev->dev, "%s\n", __func__); |
@@ -208,9 +209,12 @@ static int tps65217_charger_probe(struct platform_device *pdev) | |||
208 | charger->tps = tps; | 209 | charger->tps = tps; |
209 | charger->dev = &pdev->dev; | 210 | charger->dev = &pdev->dev; |
210 | 211 | ||
212 | cfg.of_node = pdev->dev.of_node; | ||
213 | cfg.drv_data = charger; | ||
214 | |||
211 | charger->ac = devm_power_supply_register(&pdev->dev, | 215 | charger->ac = devm_power_supply_register(&pdev->dev, |
212 | &tps65217_charger_desc, | 216 | &tps65217_charger_desc, |
213 | NULL); | 217 | &cfg); |
214 | if (IS_ERR(charger->ac)) { | 218 | if (IS_ERR(charger->ac)) { |
215 | dev_err(&pdev->dev, "failed: power supply register\n"); | 219 | dev_err(&pdev->dev, "failed: power supply register\n"); |
216 | return PTR_ERR(charger->ac); | 220 | return PTR_ERR(charger->ac); |