mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] gpio: sysfs: free the chip attribute group name on unexport
@ 2026-11-30 20:20 Arun Iyengar via B4 Relay
  2026-12-02  8:50 ` Bartosz Golaszewski
  0 siblings, 1 reply; 2+ messages in thread
From: Arun Iyengar via B4 Relay @ 2026-11-30 20:20 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski
  Cc: linux-gpio, linux-kernel, stable, Arun Iyengar

From: Arun Iyengar <aiyengar1990@gmail.com>

gpiod_export() allocates chip_attr_group.name but gpiod_unexport()
never frees it, leaking it on every unexport.

Fixes: 4fa93223e03e ("gpio: sysfs: export the GPIO directory locally in the gpiochip<id> directory")
Cc: stable@vger.kernel.org
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
Found with kmemleak on an Orange Pi 5. 1000 sysfs export/unexport
cycles: 809 leaked names before, 0 after.

Developed with Claude (Anthropic), which wrote the code and the commit
message. I reviewed the change.
---
 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 08f514992569..d0798b3f5383 100644
--- a/drivers/gpio/gpiolib-sysfs.c
+++ b/drivers/gpio/gpiolib-sysfs.c
@@ -958,6 +958,7 @@ static void gpiod_unexport_unlocked(struct gpio_desc *desc)
 
 	sysfs_remove_groups(desc_data->parent,
 			    desc_data->chip_attr_groups);
+	kfree(desc_data->chip_attr_group.name);
 
 	mutex_destroy(&desc_data->mutex);
 	kfree(desc_data);

---
base-commit: 838e2af4fde3f180abdd0e4755be078be7e132a1
change-id: 20261129-gpio-sysfs-unexport-leak-4ebc3b9a7179

Best regards,
--  
Arun Iyengar <aiyengar1990@gmail.com>



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

* Re: [PATCH] gpio: sysfs: free the chip attribute group name on unexport
  2026-11-30 20:20 [PATCH] gpio: sysfs: free the chip attribute group name on unexport Arun Iyengar via B4 Relay
@ 2026-12-02  8:50 ` Bartosz Golaszewski
  0 siblings, 0 replies; 2+ messages in thread
From: Bartosz Golaszewski @ 2026-12-02  8:50 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Arun Iyengar
  Cc: Bartosz Golaszewski, linux-gpio, linux-kernel, stable


On Mon, 30 Nov 2026 20:20:19 +0000, Arun Iyengar wrote:
> gpiod_export() allocates chip_attr_group.name but gpiod_unexport()
> never frees it, leaking it on every unexport.
> 
> 

Applied, thanks!

[1/1] gpio: sysfs: free the chip attribute group name on unexport
      https://git.kernel.org/brgl/c/e3bff42c728585cadafee4b18db9386408465cfc

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

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

end of thread, other threads:[~2026-12-02  8:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-30 20:20 [PATCH] gpio: sysfs: free the chip attribute group name on unexport Arun Iyengar via B4 Relay
2026-12-02  8: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

all inboxes | Powered by JetHome®