leds/led-class: Add missing put_device()
Devices found by class_find_device must be freed with put_device().
Otherwise the reference count will not work properly.
Fixes: a96aa64cb5
("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>
This commit is contained in:
parent
4fc5af8683
commit
e5b5a61fcb
|
@ -228,12 +228,15 @@ static int led_classdev_next_name(const char *init_name, char *name,
|
||||||
{
|
{
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
struct device *dev;
|
||||||
|
|
||||||
strlcpy(name, init_name, len);
|
strlcpy(name, init_name, len);
|
||||||
|
|
||||||
while (class_find_device(leds_class, NULL, name, match_name) &&
|
while ((ret < len) &&
|
||||||
(ret < len))
|
(dev = class_find_device(leds_class, NULL, name, match_name))) {
|
||||||
|
put_device(dev);
|
||||||
ret = snprintf(name, len, "%s_%u", init_name, ++i);
|
ret = snprintf(name, len, "%s_%u", init_name, ++i);
|
||||||
|
}
|
||||||
|
|
||||||
if (ret >= len)
|
if (ret >= len)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
Loading…
Reference in New Issue