Commit ed041997 authored by Navid Emamdoost's avatar Navid Emamdoost Committed by Greg Kroah-Hartman

gpio: arizona: put pm_runtime in case of failure

[ Upstream commit 861254d8 ]

Calling pm_runtime_get_sync increments the counter even in case of
failure, causing incorrect ref count if pm_runtime_put is not called in
error handling paths. Call pm_runtime_put if pm_runtime_get_sync fails.
Signed-off-by: default avatarNavid Emamdoost <navid.emamdoost@gmail.com>
Acked-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20200605030052.78235-1-navid.emamdoost@gmail.comSigned-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent dd1e0a7b
...@@ -69,6 +69,7 @@ static int arizona_gpio_get(struct gpio_chip *chip, unsigned offset) ...@@ -69,6 +69,7 @@ static int arizona_gpio_get(struct gpio_chip *chip, unsigned offset)
ret = pm_runtime_get_sync(chip->parent); ret = pm_runtime_get_sync(chip->parent);
if (ret < 0) { if (ret < 0) {
dev_err(chip->parent, "Failed to resume: %d\n", ret); dev_err(chip->parent, "Failed to resume: %d\n", ret);
pm_runtime_put_autosuspend(chip->parent);
return ret; return ret;
} }
...@@ -77,12 +78,15 @@ static int arizona_gpio_get(struct gpio_chip *chip, unsigned offset) ...@@ -77,12 +78,15 @@ static int arizona_gpio_get(struct gpio_chip *chip, unsigned offset)
if (ret < 0) { if (ret < 0) {
dev_err(chip->parent, "Failed to drop cache: %d\n", dev_err(chip->parent, "Failed to drop cache: %d\n",
ret); ret);
pm_runtime_put_autosuspend(chip->parent);
return ret; return ret;
} }
ret = regmap_read(arizona->regmap, reg, &val); ret = regmap_read(arizona->regmap, reg, &val);
if (ret < 0) if (ret < 0) {
pm_runtime_put_autosuspend(chip->parent);
return ret; return ret;
}
pm_runtime_mark_last_busy(chip->parent); pm_runtime_mark_last_busy(chip->parent);
pm_runtime_put_autosuspend(chip->parent); pm_runtime_put_autosuspend(chip->parent);
......
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