[PATCH RFC/RFT 03/15] gpio: sysfs: call mutex_destroy() in gpiod_unexport()

Bartosz Golaszewski posted 15 patches 4 months ago
There is a newer version of this series
[PATCH RFC/RFT 03/15] gpio: sysfs: call mutex_destroy() in gpiod_unexport()
Posted by Bartosz Golaszewski 4 months ago
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

While not critical, it's useful to have the corresponding call to
mutex_destroy() whenever we use mutex_init(). Add the call right before
kfreeing the GPIO data.

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 4a3aa09dad9d54dc77f28d596723fd5546cb3ae8..cd3381a4bc93a94b9a975248ae3e4bd8c2a3eb4b 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.48.1
Re: [PATCH RFC/RFT 03/15] gpio: sysfs: call mutex_destroy() in gpiod_unexport()
Posted by Linus Walleij 4 months ago
On Tue, Jun 10, 2025 at 4:38 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:

> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> While not critical, it's useful to have the corresponding call to
> mutex_destroy() whenever we use mutex_init(). Add the call right before
> kfreeing the GPIO data.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij