* [PATCH] gpio: xilinx: fix runtime PM leak on request error path
@ 2026-09-23 11:39 Ridham Khurana
2026-09-28 8:29 ` Bartosz Golaszewski
0 siblings, 1 reply; 2+ messages in thread
From: Ridham Khurana @ 2026-09-23 11:39 UTC (permalink / raw)
To: Shubhrajyoti Datta, Linus Walleij, Bartosz Golaszewski
Cc: Srinivas Neeli, Michal Simek, linux-gpio, linux-arm-kernel,
linux-kernel, Shuah Khan, Jori Koolstra, Brigham Campbell,
linux-kernel-mentees, Ridham Khurana, stable
pm_runtime_get_sync() leaves the usage counter incremented even when it
fails, and xgpio_request() returns the error without dropping it.
gpiolib does not call ->free() when ->request() fails, so xgpio_free(),
which holds the only matching pm_runtime_put(), never runs. The reference
is leaked and the controller can no longer runtime-suspend, so its clock
stays enabled.
Switch to pm_runtime_resume_and_get(), which only increments the usage
counter on success.
Fixes: 26b04774621e ("gpio: gpio-xilinx: Add support for suspend and resume")
Cc: stable@vger.kernel.org
Signed-off-by: Ridham Khurana <khurana.ridham222@gmail.com>
---
Build-tested on arm64 with CONFIG_GPIO_XILINX=m. Not tested on hardware.
drivers/gpio/gpio-xilinx.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c
index 532205175827..9406ce85f933 100644
--- a/drivers/gpio/gpio-xilinx.c
+++ b/drivers/gpio/gpio-xilinx.c
@@ -271,14 +271,7 @@ static void xgpio_save_regs(struct xgpio_instance *chip)
static int xgpio_request(struct gpio_chip *chip, unsigned int offset)
{
- int ret;
-
- ret = pm_runtime_get_sync(chip->parent);
- /*
- * If the device is already active pm_runtime_get() will return 1 on
- * success, but gpio_request still needs to return 0.
- */
- return ret < 0 ? ret : 0;
+ return pm_runtime_resume_and_get(chip->parent);
}
static void xgpio_free(struct gpio_chip *chip, unsigned int offset)
--
2.47.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] gpio: xilinx: fix runtime PM leak on request error path
2026-09-23 11:39 [PATCH] gpio: xilinx: fix runtime PM leak on request error path Ridham Khurana
@ 2026-09-28 8:29 ` Bartosz Golaszewski
0 siblings, 0 replies; 2+ messages in thread
From: Bartosz Golaszewski @ 2026-09-28 8:29 UTC (permalink / raw)
To: Shubhrajyoti Datta, Linus Walleij, Bartosz Golaszewski,
Ridham Khurana
Cc: Bartosz Golaszewski, Srinivas Neeli, Michal Simek, linux-gpio,
linux-arm-kernel, linux-kernel, Shuah Khan, Jori Koolstra,
Brigham Campbell, linux-kernel-mentees, stable
On Wed, 23 Sep 2026 11:39:02 +0000, Ridham Khurana wrote:
> pm_runtime_get_sync() leaves the usage counter incremented even when it
> fails, and xgpio_request() returns the error without dropping it.
>
> gpiolib does not call ->free() when ->request() fails, so xgpio_free(),
> which holds the only matching pm_runtime_put(), never runs. The reference
> is leaked and the controller can no longer runtime-suspend, so its clock
> stays enabled.
>
> [...]
Applied, thanks!
[1/1] gpio: xilinx: fix runtime PM leak on request error path
https://git.kernel.org/brgl/c/ff82fc3a4a1d417dee1229681cc5285986edb1fa
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-28 8:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-23 11:39 [PATCH] gpio: xilinx: fix runtime PM leak on request error path Ridham Khurana
2026-09-28 8:29 ` Bartosz Golaszewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox