Skip to contentSkip to conversation

gpio: sysfs: fix memory leaks

PATCH In review Johan Hovold 2 participants 5 messages Jan 26, 2015 – Jan 30, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover gpio: sysfs: fix memory leaks

Here are two more fixes for long-standing memory leaks in the gpio sysfs interface (for v3.19).

Johan

Johan Hovold (2):
gpio: sysfs: fix memory leak in gpiod_export_link
gpio: sysfs: fix memory leak in gpiod_sysfs_set_active_low

 drivers/gpio/gpiolib-sysfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Signature · 1 line
2.0.5
#1 lore raw

PATCH 1/2 gpio: sysfs: fix memory leak in gpiod_export_link

Fix memory leak in the gpio sysfs interface due to failure to drop reference to device returned by class_find_device when creating a link.

Fixes a4177ee7f1a8 ("gpiolib: allow exported GPIO nodes to be named

using sysfs links")

Cc stable <[email protected]> # v2.6.32
---
 drivers/gpio/gpiolib-sysfs.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpio/gpiolib-sysfs.c +1 -0
index 14c4f94813eb..820b1e70ddfe 100644
@@ -648,6 +648,7 @@ int gpiod_export_link(struct device *dev, const char *name,
 		if (tdev != NULL) {
 			status = sysfs_create_link(&dev->kobj, &tdev->kobj,
 						name);
+			put_device(tdev);
 		} else {
 			status = -ENODEV;
 		}
Signature · 1 line
2.0.5
#2 lore raw

Re: [PATCH 1/2] gpio: sysfs: fix memory leak in gpiod_export_link

Quoted 7 lines · Johan Hovold

Fix memory leak in the gpio sysfs interface due to failure to drop reference to device returned by class_find_device when creating a link.

Fixes a4177ee7f1a8 ("gpiolib: allow exported GPIO nodes to be named

using sysfs links")

Cc stable <[email protected]> # v2.6.32

Patch applied.

Let's see if I get it into v3.19 properly...

Yours,
Linus Walleij

#3 lore raw

PATCH 2/2 gpio: sysfs: fix memory leak in gpiod_sysfs_set_active_low

In reply to Johan Hovold

Fix memory leak in the gpio sysfs interface due to failure to drop reference to device returned by class_find_device when setting the gpio-line polarity.

Fixes 0769746183ca ("gpiolib: add support for changing value polarity

in sysfs")

Cc stable <[email protected]> # v2.6.33
---
 drivers/gpio/gpiolib-sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpiolib-sysfs.c +1 -1
index 820b1e70ddfe..4908d09873e5 100644
@@ -696,7 +696,7 @@ int gpiod_sysfs_set_active_low(struct gpio_desc *desc, int value)
 	}
 
 	status = sysfs_set_active_low(desc, dev, value);
-
+	put_device(dev);
 unlock:
 	mutex_unlock(&sysfs_lock);
 
Signature · 1 line
2.0.5
#4 lore raw

Re: [PATCH 2/2] gpio: sysfs: fix memory leak in gpiod_sysfs_set_active_low

Quoted 8 lines · Johan Hovold

Fix memory leak in the gpio sysfs interface due to failure to drop reference to device returned by class_find_device when setting the gpio-line polarity.

Fixes 0769746183ca ("gpiolib: add support for changing value polarity

in sysfs")

Cc stable <[email protected]> # v2.6.33

Patch applied.

Yours,
Linus Walleij