[PATCH AUTOSEL 5.4 288/330] gpio: rcar: Fix runtime PM imbalance on error

From: Sasha Levin
Date: Thu Sep 17 2020 - 22:55:24 EST


From: Dinghao Liu <dinghao.liu@xxxxxxxxxx>

[ Upstream commit 6f8cd246411575703d9312888b70705c396b53a9 ]

pm_runtime_get_sync() increments the runtime PM usage counter even
when it returns an error code. Thus a pairing decrement is needed on
the error handling path to keep the counter balanced.

Signed-off-by: Dinghao Liu <dinghao.liu@xxxxxxxxxx>
Link: https://lore.kernel.org/r/20200522080839.32612-1-dinghao.liu@xxxxxxxxxx
Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
drivers/gpio/gpio-rcar.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
index 187984d26f47a..f0b6c68e848e3 100644
--- a/drivers/gpio/gpio-rcar.c
+++ b/drivers/gpio/gpio-rcar.c
@@ -250,8 +250,10 @@ static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset)
int error;

error = pm_runtime_get_sync(p->dev);
- if (error < 0)
+ if (error < 0) {
+ pm_runtime_put(p->dev);
return error;
+ }

error = pinctrl_gpio_request(chip->base + offset);
if (error)
--
2.25.1