Linux GPIO subsystem development
 help / color / mirror / Atom feed
* [PATCH] gpio: sysfs: add missing mutex_destroy()
@ 2025-05-16 10:40 Bartosz Golaszewski
  2025-05-16 11:42 ` Johan Hovold
  0 siblings, 1 reply; 7+ messages in thread
From: Bartosz Golaszewski @ 2025-05-16 10:40 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Johan Hovold
  Cc: linux-gpio, linux-kernel, Bartosz Golaszewski, stable

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

We initialize the data->mutex in gpiod_export() but lack the
corresponding mutex_destroy() in gpiod_unexport() causing a resource
leak with mutex debugging enabled. Add the call right before kfreeing
the GPIO data.

Fixes: 6ffcb7971486 ("gpio: sysfs: use per-gpio locking")
Cc: stable@vger.kernel.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/gpio/gpiolib-sysfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
index 4a3aa09dad9d..cd3381a4bc93 100644
--- a/drivers/gpio/gpiolib-sysfs.c
+++ b/drivers/gpio/gpiolib-sysfs.c
@@ -713,6 +713,7 @@ void gpiod_unexport(struct gpio_desc *desc)
 	}
 
 	put_device(dev);
+	mutex_destroy(&data->mutex);
 	kfree(data);
 }
 EXPORT_SYMBOL_GPL(gpiod_unexport);
-- 
2.45.2


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

end of thread, other threads:[~2025-05-19 12:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-16 10:40 [PATCH] gpio: sysfs: add missing mutex_destroy() Bartosz Golaszewski
2025-05-16 11:42 ` Johan Hovold
2025-05-16 12:32   ` Bartosz Golaszewski
2025-05-16 16:58     ` Johan Hovold
2025-05-19 12:18       ` Bartosz Golaszewski
2025-05-19 12:42         ` Johan Hovold
2025-05-19 12:50           ` Bartosz Golaszewski

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