From: Lee Jones <lee@kernel.org>
To: luhongfei <luhongfei@vivo.com>
Cc: "Pavel Machek" <pavel@ucw.cz>,
"Thierry Reding" <thierry.reding@gmail.com>,
"Anjelique Melendez" <quic_amelende@quicinc.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Conor Dooley" <conor.dooley@microchip.com>,
"Dmitry Baryshkov" <dmitry.baryshkov@linaro.org>,
"Bjorn Andersson" <andersson@kernel.org>,
luhongfei <11117923@bbktel.com>,
"open list:LED SUBSYSTEM" <linux-leds@vger.kernel.org>,
"open list" <linux-kernel@vger.kernel.org>,
opensource.kernel@vivo.com
Subject: Re: [PATCH] led: qcom-lpg: Fix bugs in lpg_add_led & lpg_probe
Date: Thu, 25 May 2023 11:20:36 +0100 [thread overview]
Message-ID: <20230525102036.GB9691@google.com> (raw)
In-Reply-To: <20230515082622.24551-1-luhongfei@vivo.com>
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@vivo.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 [李琼斯]
prev parent reply other threads:[~2023-05-25 10:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-15 8:26 [PATCH] led: qcom-lpg: Fix bugs in lpg_add_led & lpg_probe luhongfei
2023-05-25 10:20 ` 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=20230525102036.GB9691@google.com \
--to=lee@kernel.org \
--cc=11117923@bbktel.com \
--cc=andersson@kernel.org \
--cc=conor.dooley@microchip.com \
--cc=dmitry.baryshkov@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=luhongfei@vivo.com \
--cc=opensource.kernel@vivo.com \
--cc=pavel@ucw.cz \
--cc=quic_amelende@quicinc.com \
--cc=thierry.reding@gmail.com \
--cc=u.kleine-koenig@pengutronix.de \
/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