[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <30218df3-55a1-4369-8591-7726b166e88f@web.de>
Date: Thu, 30 Oct 2025 11:00:08 +0100
From: Markus Elfring <Markus.Elfring@....de>
To: vulab@...as.ac.cn, linux-leds@...r.kernel.org, Lee Jones
 <lee@...nel.org>, Pavel Machek <pavel@...nel.org>
Cc: LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] leds: netxbig: fix GPIO descriptor leak in error paths
…> ---
> 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
Powered by blists - more mailing lists
 
