public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: Deepak R Varma <drv@mailo.com>
Cc: Pavel Machek <pavel@ucw.cz>,
	linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org,
	Saurabh Singh Sengar <ssengar@microsoft.com>,
	Praveen Kumar <kumarpraveen@linux.microsoft.com>
Subject: Re: [PATCH] leds: qcom-lpg: Release node reference before returning
Date: Fri, 3 Mar 2023 09:00:23 +0000	[thread overview]
Message-ID: <20230303090023.GJ2303077@google.com> (raw)
In-Reply-To: <Y+dw/0DA+j6xFiHR@ubun2204.myguest.virtualbox.org>

On Sat, 11 Feb 2023, Deepak R Varma wrote:

> The iterator for_each_available_child_of_node() increments the refcount
> of the child node it is processing. Release such a reference when the
> loop needs to breaks due to en error during its execution.
> Issue identified using for_each_child.cocci Coccinelle semantic patch.
> 
> Signed-off-by: Deepak R Varma <drv@mailo.com>
> ---
> Please note: The proposed change is compile tested only. I do not have the
> necessary hardware to perform additional testing. Please suggest if there is an
> alternate means available to further test this change.

Please send this again and include the authors.

Perhaps they would be kind enough to test it or provide guidance.
 
>  drivers/leds/rgb/leds-qcom-lpg.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-lpg.c
> index 67f48f222109..993fb9cf0204 100644
> --- a/drivers/leds/rgb/leds-qcom-lpg.c
> +++ b/drivers/leds/rgb/leds-qcom-lpg.c
> @@ -1112,8 +1112,10 @@ static int lpg_add_led(struct lpg *lpg, struct device_node *np)
>  		i = 0;
>  		for_each_available_child_of_node(np, child) {
>  			ret = lpg_parse_channel(lpg, child, &led->channels[i]);
> -			if (ret < 0)
> +			if (ret < 0) {
> +				of_node_put(child);
>  				return ret;
> +			}
>  
>  			info[i].color_index = led->channels[i]->color;
>  			info[i].intensity = 0;
> @@ -1291,8 +1293,10 @@ static int lpg_probe(struct platform_device *pdev)
>  
>  	for_each_available_child_of_node(pdev->dev.of_node, np) {
>  		ret = lpg_add_led(lpg, np);
> -		if (ret)
> +		if (ret) {
> +			of_node_put(np);
>  			return ret;
> +		}
>  	}
>  
>  	for (i = 0; i < lpg->num_channels; i++)
> -- 
> 2.34.1
> 
> 
> 

-- 
Lee Jones [李琼斯]

      reply	other threads:[~2023-03-03  9:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-11 10:42 [PATCH] leds: qcom-lpg: Release node reference before returning Deepak R Varma
2023-03-03  9:00 ` Lee Jones [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=20230303090023.GJ2303077@google.com \
    --to=lee@kernel.org \
    --cc=drv@mailo.com \
    --cc=kumarpraveen@linux.microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=ssengar@microsoft.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox