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
  0 siblings, 0 replies; only message 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] only message in thread

only message in thread, other threads:[~2026-11-30 20:20 UTC | newest]

Thread overview: (only message) (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

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®