Commit b2f6cb78 authored by Zhang Qilong's avatar Zhang Qilong Committed by Sebastian Reichel

power: supply: bq24190_charger: fix reference leak

pm_runtime_get_sync will increment pm usage counter even it
failed. Forgetting to call pm_runtime_put_noidle will result
in reference leak in callers(bq24190_sysfs_show,
bq24190_charger_get_property, bq24190_charger_set_property,
bq24190_battery_get_property, bq24190_battery_set_property),
so we should fix it.

Fixes: f385e6e2 ("power: bq24190_charger: Use PM runtime autosuspend")
Signed-off-by: default avatarZhang Qilong <zhangqilong3@huawei.com>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent 7776bcd2
...@@ -448,8 +448,10 @@ static ssize_t bq24190_sysfs_show(struct device *dev, ...@@ -448,8 +448,10 @@ static ssize_t bq24190_sysfs_show(struct device *dev,
return -EINVAL; return -EINVAL;
ret = pm_runtime_get_sync(bdi->dev); ret = pm_runtime_get_sync(bdi->dev);
if (ret < 0) if (ret < 0) {
pm_runtime_put_noidle(bdi->dev);
return ret; return ret;
}
ret = bq24190_read_mask(bdi, info->reg, info->mask, info->shift, &v); ret = bq24190_read_mask(bdi, info->reg, info->mask, info->shift, &v);
if (ret) if (ret)
...@@ -1077,8 +1079,10 @@ static int bq24190_charger_get_property(struct power_supply *psy, ...@@ -1077,8 +1079,10 @@ static int bq24190_charger_get_property(struct power_supply *psy,
dev_dbg(bdi->dev, "prop: %d\n", psp); dev_dbg(bdi->dev, "prop: %d\n", psp);
ret = pm_runtime_get_sync(bdi->dev); ret = pm_runtime_get_sync(bdi->dev);
if (ret < 0) if (ret < 0) {
pm_runtime_put_noidle(bdi->dev);
return ret; return ret;
}
switch (psp) { switch (psp) {
case POWER_SUPPLY_PROP_CHARGE_TYPE: case POWER_SUPPLY_PROP_CHARGE_TYPE:
...@@ -1149,8 +1153,10 @@ static int bq24190_charger_set_property(struct power_supply *psy, ...@@ -1149,8 +1153,10 @@ static int bq24190_charger_set_property(struct power_supply *psy,
dev_dbg(bdi->dev, "prop: %d\n", psp); dev_dbg(bdi->dev, "prop: %d\n", psp);
ret = pm_runtime_get_sync(bdi->dev); ret = pm_runtime_get_sync(bdi->dev);
if (ret < 0) if (ret < 0) {
pm_runtime_put_noidle(bdi->dev);
return ret; return ret;
}
switch (psp) { switch (psp) {
case POWER_SUPPLY_PROP_ONLINE: case POWER_SUPPLY_PROP_ONLINE:
...@@ -1410,8 +1416,10 @@ static int bq24190_battery_get_property(struct power_supply *psy, ...@@ -1410,8 +1416,10 @@ static int bq24190_battery_get_property(struct power_supply *psy,
dev_dbg(bdi->dev, "prop: %d\n", psp); dev_dbg(bdi->dev, "prop: %d\n", psp);
ret = pm_runtime_get_sync(bdi->dev); ret = pm_runtime_get_sync(bdi->dev);
if (ret < 0) if (ret < 0) {
pm_runtime_put_noidle(bdi->dev);
return ret; return ret;
}
switch (psp) { switch (psp) {
case POWER_SUPPLY_PROP_STATUS: case POWER_SUPPLY_PROP_STATUS:
...@@ -1456,8 +1464,10 @@ static int bq24190_battery_set_property(struct power_supply *psy, ...@@ -1456,8 +1464,10 @@ static int bq24190_battery_set_property(struct power_supply *psy,
dev_dbg(bdi->dev, "prop: %d\n", psp); dev_dbg(bdi->dev, "prop: %d\n", psp);
ret = pm_runtime_get_sync(bdi->dev); ret = pm_runtime_get_sync(bdi->dev);
if (ret < 0) if (ret < 0) {
pm_runtime_put_noidle(bdi->dev);
return ret; return ret;
}
switch (psp) { switch (psp) {
case POWER_SUPPLY_PROP_ONLINE: case POWER_SUPPLY_PROP_ONLINE:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment