From: Markus Elfring <Markus.Elfring@web.de>
To: vulab@iscas.ac.cn, linux-leds@vger.kernel.org,
Lee Jones <lee@kernel.org>, Pavel Machek <pavel@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] leds: netxbig: fix GPIO descriptor leak in error paths
Date: Thu, 30 Oct 2025 11:00:08 +0100 [thread overview]
Message-ID: <30218df3-55a1-4369-8591-7726b166e88f@web.de> (raw)
In-Reply-To: <20251030025312.1623-1-vulab@iscas.ac.cn>
…> ---
> Changes in v2:
> - Consolidate PTR_ERR(gpiod) extraction into err_gpiod_put label
…
Thanks.
I see another refinement possibility.
…> +++ b/drivers/leds/leds-netxbig.c
…> @@ -374,46 +377,61 @@ static int netxbig_gpio_ext_get(struct device *dev,
> for (i = 0; i < num_addr; i++) {
> gpiod = gpiod_get_index(gpio_ext_dev, "addr", i,
> GPIOD_OUT_LOW);
> - if (IS_ERR(gpiod))
> - return PTR_ERR(gpiod);
> + if (IS_ERR(gpiod)) {
> + ret = PTR_ERR(gpiod);
Why do propose to add this statement here?
> + goto err_free_addr;
> + }
…> +err_gpiod_put:
> + ret = PTR_ERR(gpiod);
> +err_free_data:
> + for (i = 0; i < gpio_ext->num_data; i++)
> + gpiod_put(gpio_ext->data[i]);
Would you find the following source code usable between the other two labels?
err_set_code:
ret = PTR_ERR(gpiod);
> +err_free_addr:
> + for (i = 0; i < gpio_ext->num_addr; i++)
> + gpiod_put(gpio_ext->addr[i]);
> + return ret;
> }
…
Regards,
Markus
next prev parent reply other threads:[~2025-10-30 10:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-28 8:21 [PATCH] " Haotian Zhang
2025-10-29 12:55 ` Markus Elfring
2025-10-30 2:53 ` [PATCH v2] " Haotian Zhang
2025-10-30 10:00 ` Markus Elfring [this message]
2025-10-30 18:06 ` kernel test robot
2025-10-30 22:29 ` kernel test robot
2025-10-31 2:16 ` [PATCH v3] " Haotian Zhang
2025-11-13 13:52 ` (subset) " Lee Jones
2025-11-18 20:01 ` Andy Shevchenko
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=30218df3-55a1-4369-8591-7726b166e88f@web.de \
--to=markus.elfring@web.de \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@kernel.org \
--cc=vulab@iscas.ac.cn \
/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
all inboxes | Powered by JetHome®