All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jacek Anaszewski <jacek.anaszewski@gmail.com>
To: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>,
	Alan Tull <delicious.quinoa@gmail.com>,
	Bryan Wu <cooloney@gmail.com>, Richard Purdie <rpurdie@rpsys.net>,
	Jacek Anaszewski <j.anaszewski@samsung.com>,
	linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] leds/led-class: Add missing put_device()
Date: Fri, 31 Jul 2015 18:15:50 +0200	[thread overview]
Message-ID: <55BB9F36.8040809@gmail.com> (raw)
In-Reply-To: <1438342581-9763-1-git-send-email-ricardo.ribalda@gmail.com>

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@gmail.com>
> Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
> ---
> Thanks Alan for the initial report and Jacek for the review
>
> v2: Changes from Jacek Anaszewski <jacek.anaszewski@gmail.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@samsung.com>

-- 
Best Regards,
Jacek Anaszewski

      reply	other threads:[~2015-07-31 16:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-31 11:36 [PATCH v2] leds/led-class: Add missing put_device() Ricardo Ribalda Delgado
2015-07-31 16:15 ` Jacek Anaszewski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55BB9F36.8040809@gmail.com \
    --to=jacek.anaszewski@gmail.com \
    --cc=cooloney@gmail.com \
    --cc=delicious.quinoa@gmail.com \
    --cc=j.anaszewski@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=ricardo.ribalda@gmail.com \
    --cc=rpurdie@rpsys.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.