Commit e3edeb67 authored by Johan Hovold's avatar Johan Hovold Committed by Luis Henriques

gpio: sysfs: fix memory leak in gpiod_export_link

commit 0f303db0 upstream.

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: a4177ee7 ("gpiolib: allow exported GPIO nodes to be named
using sysfs links")
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
[ luis: backported to 3.16:
  - file rename: drivers/gpio/gpiolib-sysfs.c -> drivers/gpio/gpiolib.c ]
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent a5ff5fd2
......@@ -911,6 +911,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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment