Commit 8566a606 authored by Johan Hovold's avatar Johan Hovold Committed by Zefan Li

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>
[lizf: Backported to 3.4: adjust filename]
Signed-off-by: default avatarZefan Li <lizefan@huawei.com>
parent db6c390a
...@@ -825,6 +825,7 @@ int gpio_export_link(struct device *dev, const char *name, unsigned gpio) ...@@ -825,6 +825,7 @@ int gpio_export_link(struct device *dev, const char *name, unsigned gpio)
if (tdev != NULL) { if (tdev != NULL) {
status = sysfs_create_link(&dev->kobj, &tdev->kobj, status = sysfs_create_link(&dev->kobj, &tdev->kobj,
name); name);
put_device(tdev);
} else { } else {
status = -ENODEV; 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