summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorGeorges Savoundararadj <savoundg@gmail.com>2016-09-07 18:38:15 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-10-31 04:14:00 -0600
commit936ea759b70591231f47b10fd8fde20d8d210c2b (patch)
treea4ba658d7649d5b9e3c8a1fdcb0485bbc2060597 /drivers/power
parentfb911dfec0b0186d64604bbbf62dfdbb42a1aa79 (diff)
power: bq24257: Fix use of uninitialized pointer bq->charger
commit 0610735928ee47870e083d5901caa371089216f1 upstream. bq->charger is initialized in bq24257_power_supply_init. Therefore, bq24257_power_supply_init should be called before the registration of the IRQ handler bq24257_irq_handler_thread that calls power_supply_changed(bq->charger). Signed-off-by: Georges Savoundararadj <savoundg@gmail.com> Cc: Aurelien Chanot <chanot.a@gmail.com> Cc: Andreas Dannenberg <dannenberg@ti.com> Cc: Sebastian Reichel <sre@kernel.org> Cc: David Woodhouse <dwmw2@infradead.org> Fixes: 2219a935963e ("power_supply: Add TI BQ24257 charger driver") Signed-off-by: Sebastian Reichel <sre@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/bq24257_charger.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/power/bq24257_charger.c b/drivers/power/bq24257_charger.c
index 1fea2c7ef97f..6fc31bdc639b 100644
--- a/drivers/power/bq24257_charger.c
+++ b/drivers/power/bq24257_charger.c
@@ -1068,6 +1068,12 @@ static int bq24257_probe(struct i2c_client *client,
return ret;
}
+ ret = bq24257_power_supply_init(bq);
+ if (ret < 0) {
+ dev_err(dev, "Failed to register power supply\n");
+ return ret;
+ }
+
ret = devm_request_threaded_irq(dev, client->irq, NULL,
bq24257_irq_handler_thread,
IRQF_TRIGGER_FALLING |
@@ -1078,12 +1084,6 @@ static int bq24257_probe(struct i2c_client *client,
return ret;
}
- ret = bq24257_power_supply_init(bq);
- if (ret < 0) {
- dev_err(dev, "Failed to register power supply\n");
- return ret;
- }
-
ret = sysfs_create_group(&bq->charger->dev.kobj, &bq24257_attr_group);
if (ret < 0) {
dev_err(dev, "Can't create sysfs entries\n");