mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] gpio: arizona: Fix runtime PM leak in arizona_gpio_direction_out()
@ 2026-09-16  9:47 Wentao Liang
  2026-09-16 10:01 ` Charles Keepax
  2026-09-17  9:51 ` Bartosz Golaszewski
  0 siblings, 2 replies; 3+ messages in thread
From: Wentao Liang @ 2026-09-16  9:47 UTC (permalink / raw)
  To: brgl
  Cc: ckeepax, linusw, linux-gpio, linux-kernel, patches, Wentao Liang, stable

Switching a persistent GPIO line from input to output acquires a
runtime PM reference on the parent device, but if the subsequent
regmap_update_bits() fails the reference is never dropped and no later
direction_in() can balance it since the direction was never changed.
Drop the reference on the update failure path.

Fixes: 27a49ed17e22 ("gpio: arizona: Add support for GPIOs that need to be maintained")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/gpio/gpio-arizona.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-arizona.c b/drivers/gpio/gpio-arizona.c
index a7e98d395d8e..88cf013f0d90 100644
--- a/drivers/gpio/gpio-arizona.c
+++ b/drivers/gpio/gpio-arizona.c
@@ -115,8 +115,12 @@ static int arizona_gpio_direction_out(struct gpio_chip *chip,
 	if (value)
 		value = ARIZONA_GPN_LVL;
 
-	return regmap_update_bits(arizona->regmap, ARIZONA_GPIO1_CTRL + offset,
-				  ARIZONA_GPN_DIR | ARIZONA_GPN_LVL, value);
+	ret = regmap_update_bits(arizona->regmap, ARIZONA_GPIO1_CTRL + offset,
+				 ARIZONA_GPN_DIR | ARIZONA_GPN_LVL, value);
+	if (ret < 0 && (val & ARIZONA_GPN_DIR) && persistent)
+		pm_runtime_put_autosuspend(chip->parent);
+
+	return ret;
 }
 
 static int arizona_gpio_set(struct gpio_chip *chip, unsigned int offset,
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gpio: arizona: Fix runtime PM leak in arizona_gpio_direction_out()
  2026-09-16  9:47 [PATCH] gpio: arizona: Fix runtime PM leak in arizona_gpio_direction_out() Wentao Liang
@ 2026-09-16 10:01 ` Charles Keepax
  2026-09-17  9:51 ` Bartosz Golaszewski
  1 sibling, 0 replies; 3+ messages in thread
From: Charles Keepax @ 2026-09-16 10:01 UTC (permalink / raw)
  To: Wentao Liang
  Cc: brgl, ckeepax, linusw, linux-gpio, linux-kernel, patches, stable

On Wed, Sep 16, 2026 at 09:47:01AM +0000, Wentao Liang wrote:
> Switching a persistent GPIO line from input to output acquires a
> runtime PM reference on the parent device, but if the subsequent
> regmap_update_bits() fails the reference is never dropped and no later
> direction_in() can balance it since the direction was never changed.
> Drop the reference on the update failure path.
> 
> Fixes: 27a49ed17e22 ("gpio: arizona: Add support for GPIOs that need to be maintained")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---

Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>

Thanks,
Charles

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gpio: arizona: Fix runtime PM leak in arizona_gpio_direction_out()
  2026-09-16  9:47 [PATCH] gpio: arizona: Fix runtime PM leak in arizona_gpio_direction_out() Wentao Liang
  2026-09-16 10:01 ` Charles Keepax
@ 2026-09-17  9:51 ` Bartosz Golaszewski
  1 sibling, 0 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2026-09-17  9:51 UTC (permalink / raw)
  To: brgl, Wentao Liang
  Cc: Bartosz Golaszewski, ckeepax, linusw, linux-gpio, linux-kernel,
	patches, stable


On Wed, 16 Sep 2026 09:47:01 +0000, Wentao Liang wrote:
> Switching a persistent GPIO line from input to output acquires a
> runtime PM reference on the parent device, but if the subsequent
> regmap_update_bits() fails the reference is never dropped and no later
> direction_in() can balance it since the direction was never changed.
> Drop the reference on the update failure path.
> 
> 
> [...]

Applied, thanks!

[1/1] gpio: arizona: Fix runtime PM leak in arizona_gpio_direction_out()
      https://git.kernel.org/brgl/c/e9d810279f84b30738f7790c0ed15f8dd5b9024a

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-17  9:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-16  9:47 [PATCH] gpio: arizona: Fix runtime PM leak in arizona_gpio_direction_out() Wentao Liang
2026-09-16 10:01 ` Charles Keepax
2026-09-17  9:51 ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®