[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <55BB9F36.8040809@gmail.com>
Date: Fri, 31 Jul 2015 18:15:50 +0200
From: Jacek Anaszewski <jacek.anaszewski@...il.com>
To: Ricardo Ribalda Delgado <ricardo.ribalda@...il.com>,
Alan Tull <delicious.quinoa@...il.com>,
Bryan Wu <cooloney@...il.com>,
Richard Purdie <rpurdie@...ys.net>,
Jacek Anaszewski <j.anaszewski@...sung.com>,
linux-leds@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] leds/led-class: Add missing put_device()
Hi Ricardo,
Thanks for the update.
On 31.07.2015 13:36, Ricardo Ribalda Delgado wrote:
> 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@...il.com>
> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@...il.com>
> ---
> Thanks Alan for the initial report and Jacek for the review
>
> v2: Changes from Jacek Anaszewski <jacek.anaszewski@...il.com>
> If ret <= len device was not relased
>
> drivers/leds/led-class.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
> index beabfbc6f7cd..ca51d58bed24 100644
> --- a/drivers/leds/led-class.c
> +++ b/drivers/leds/led-class.c
> @@ -228,12 +228,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;
>
Acked-by: Jacek Anaszewski <j.anaszewski@...sung.com>
--
Best Regards,
Jacek Anaszewski
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists