summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRicardo Ribalda Delgado <ricardo.ribalda@gmail.com>2015-07-31 13:36:21 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-10-22 14:43:14 -0700
commit438437983e0cefa439e9b161f74b805d0416eec0 (patch)
treea3fa1e096dfc626154f87191a75564c49a9df41c /drivers
parent6cdd2beb9a3627de301bc03474e0805e4b53efba (diff)
downloadlinux-stable-438437983e0cefa439e9b161f74b805d0416eec0.tar.gz
linux-stable-438437983e0cefa439e9b161f74b805d0416eec0.tar.bz2
linux-stable-438437983e0cefa439e9b161f74b805d0416eec0.zip
leds/led-class: Add missing put_device()
commit e5b5a61fcb3743f1dacf9e20d28f48423cecf0c1 upstream. Devices found by class_find_device must be freed with put_device(). Otherwise the reference count will not work properly. Fixes: a96aa64cb572 ("leds/led-class: Handle LEDs with the same name") Reported-by: Alan Tull <delicious.quinoa@gmail.com> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/leds/led-class.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index 7fb2a19ac649..557f8a53a062 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -223,12 +223,15 @@ static int led_classdev_next_name(const char *init_name, char *name,
{
unsigned int i = 0;
int ret = 0;
+ struct device *dev;
strlcpy(name, init_name, len);
- while (class_find_device(leds_class, NULL, name, match_name) &&
- (ret < len))
+ while ((ret < len) &&
+ (dev = class_find_device(leds_class, NULL, name, match_name))) {
+ put_device(dev);
ret = snprintf(name, len, "%s_%u", init_name, ++i);
+ }
if (ret >= len)
return -ENOMEM;