lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20230525102036.GB9691@google.com>
Date:   Thu, 25 May 2023 11:20:36 +0100
From:   Lee Jones <lee@...nel.org>
To:     luhongfei <luhongfei@...o.com>
Cc:     Pavel Machek <pavel@....cz>,
        Thierry Reding <thierry.reding@...il.com>,
        Anjelique Melendez <quic_amelende@...cinc.com>,
        Uwe Kleine-König 
        <u.kleine-koenig@...gutronix.de>,
        Conor Dooley <conor.dooley@...rochip.com>,
        Dmitry Baryshkov <dmitry.baryshkov@...aro.org>,
        Bjorn Andersson <andersson@...nel.org>,
        luhongfei <11117923@...tel.com>,
        "open list:LED SUBSYSTEM" <linux-leds@...r.kernel.org>,
        open list <linux-kernel@...r.kernel.org>,
        opensource.kernel@...o.com
Subject: Re: [PATCH] led: qcom-lpg: Fix bugs in lpg_add_led & lpg_probe

Please improve the subject line.  Maybe:

  "Fix resource leaks in for_each_available_child_of_node() loops"

On Mon, 15 May 2023, luhongfei wrote:

> for_each_available_child_of_node in lpg_probe and lpg_add_led need
> to execute of_node_put before return. this patch could fix this bug.

"Ensure child node references are decremented properly in the error path."

> Signed-off-by: luhongfei <luhongfei@...o.com>

Please use your full name.

> ---
>  drivers/leds/rgb/leds-qcom-lpg.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>  mode change 100644 => 100755 drivers/leds/rgb/leds-qcom-lpg.c
> 
> diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-lpg.c
> index 55a037234df1..0e8ff36c4bf7
> --- a/drivers/leds/rgb/leds-qcom-lpg.c
> +++ b/drivers/leds/rgb/leds-qcom-lpg.c
> @@ -1173,8 +1173,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;
> @@ -1352,8 +1354,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;
> +		}
>  	}

Code is fine.

-- 
Lee Jones [李琼斯]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ