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] [thread-next>] [day] [month] [year] [list]
Message-ID: <d2b3fe8b-9f86-4b39-ae95-399cb7da685a@baylibre.com>
Date: Wed, 6 Aug 2025 21:07:23 -0500
From: David Lechner <dlechner@...libre.com>
To: Salah Triki <salah.triki@...il.com>,
 Michael Hennerich <Michael.Hennerich@...log.com>,
 Nuno Sa <nuno.sa@...log.com>, Lars-Peter Clausen <lars@...afoo.de>,
 Jonathan Cameron <jic23@...nel.org>, Andy Shevchenko <andy@...nel.org>,
 linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] iio: adc: ad9467: Replace PTR_ERR_OR_ZERO() in
 ad9467_reset()

On 8/6/25 8:39 PM, Salah Triki wrote:
> PTR_ERR_OR_ZERO() returns 0 if the argument is NULL, which can hide real
> issues when the caller expects an ERR_PTR on failure. Use a ternary
> expression instead to return the appropriate error code.
> 
> Signed-off-by: Salah Triki <salah.triki@...il.com>
> ---
>  drivers/iio/adc/ad9467.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/ad9467.c b/drivers/iio/adc/ad9467.c
> index f7a9f46ea0dc..70aee2666ff1 100644
> --- a/drivers/iio/adc/ad9467.c
> +++ b/drivers/iio/adc/ad9467.c
> @@ -945,7 +945,7 @@ static int ad9467_reset(struct device *dev)
>  
>  	gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
>  	if (IS_ERR_OR_NULL(gpio))
> -		return PTR_ERR_OR_ZERO(gpio);
> +		return gpio ? PTR_ERR(gpio) : -ENODEV;
>  
>  	fsleep(1);
>  	gpiod_set_value_cansleep(gpio, 0);

The existing code looks correct to me. The reset gpio is optional
so early return of 0 when there is no gpio seems fine. Changing it
to return an error could break existing users since it will cause
probe to fail.

Also, if the original intention was to make the gpio required, then
it should just not use devm_gpiod_get_optional() and simplify the
whole thing. But I don't think that was the intention.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ