Skip to content

Commit 861254d

Browse files
Navidemlinusw
authored andcommitted
gpio: arizona: put pm_runtime in case of failure
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: Navid Emamdoost <[email protected]> Acked-by: Charles Keepax <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent e6f390a commit 861254d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/gpio/gpio-arizona.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ static int arizona_gpio_get(struct gpio_chip *chip, unsigned offset)
6464
ret = pm_runtime_get_sync(chip->parent);
6565
if (ret < 0) {
6666
dev_err(chip->parent, "Failed to resume: %d\n", ret);
67+
pm_runtime_put_autosuspend(chip->parent);
6768
return ret;
6869
}
6970

@@ -72,12 +73,15 @@ static int arizona_gpio_get(struct gpio_chip *chip, unsigned offset)
7273
if (ret < 0) {
7374
dev_err(chip->parent, "Failed to drop cache: %d\n",
7475
ret);
76+
pm_runtime_put_autosuspend(chip->parent);
7577
return ret;
7678
}
7779

7880
ret = regmap_read(arizona->regmap, reg, &val);
79-
if (ret < 0)
81+
if (ret < 0) {
82+
pm_runtime_put_autosuspend(chip->parent);
8083
return ret;
84+
}
8185

8286
pm_runtime_mark_last_busy(chip->parent);
8387
pm_runtime_put_autosuspend(chip->parent);

0 commit comments

Comments
 (0)