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: <8b006f8f2a445215365c9aca02b88cd4f2829918.camel@gmail.com>
Date: Tue, 11 Mar 2025 09:26:37 +0000
From: Nuno Sá <noname.nuno@...il.com>
To: David Lechner <dlechner@...libre.com>, Lars-Peter Clausen
 <lars@...afoo.de>,  Michael Hennerich <Michael.Hennerich@...log.com>, Nuno
 Sá <nuno.sa@...log.com>, Esteban Blanc	
 <eblanc@...libre.com>, Jonathan Cameron <jic23@...nel.org>
Cc: linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org, kernel test
 robot	 <lkp@...el.com>, Dan Carpenter <dan.carpenter@...aro.org>
Subject: Re: [PATCH 1/5] iio: adc: ad4030: check scan_type for error

On Mon, 2025-03-10 at 15:43 -0500, David Lechner wrote:
> Check scan_type for error ad4030_get_chan_scale(). Currently, this
> should never fail, but it is good practice to always check for errors
> in case of future changes.
> 
> Calling iio_get_current_scan_type() is moved out of the if statement
> also to avoid potential issues with future changes instead of assuming
> that the non-differential case does not use extended scan_type.
> 
> Reported-by: kernel test robot <lkp@...el.com>
> Reported-by: Dan Carpenter <dan.carpenter@...aro.org>
> Closes: https://lore.kernel.org/r/202503040954.n6MhjSsV-lkp@intel.com/
> Signed-off-by: David Lechner <dlechner@...libre.com>
> ---

Reviewed-by: Nuno Sá <nuno.sa@...log.com>

>  drivers/iio/adc/ad4030.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad4030.c b/drivers/iio/adc/ad4030.c
> index
> 9a020680885d93f4da8922e5cfeecc0c7ce23f4d..af7a817e8273496e8856a5ba1a9c2e66a11f
> 0a84 100644
> --- a/drivers/iio/adc/ad4030.c
> +++ b/drivers/iio/adc/ad4030.c
> @@ -390,16 +390,18 @@ static int ad4030_get_chan_scale(struct iio_dev
> *indio_dev,
>  	struct ad4030_state *st = iio_priv(indio_dev);
>  	const struct iio_scan_type *scan_type;
>  
> +	scan_type = iio_get_current_scan_type(indio_dev, st->chip->channels);
> +	if (IS_ERR(scan_type))
> +		return PTR_ERR(scan_type);
> +
>  	if (chan->differential) {
> -		scan_type = iio_get_current_scan_type(indio_dev,
> -						      st->chip->channels);
>  		*val = (st->vref_uv * 2) / MILLI;
>  		*val2 = scan_type->realbits;
>  		return IIO_VAL_FRACTIONAL_LOG2;
>  	}
>  
>  	*val = st->vref_uv / MILLI;
> -	*val2 = chan->scan_type.realbits;
> +	*val2 = scan_type->realbits;
>  	return IIO_VAL_FRACTIONAL_LOG2;
>  }
>  
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ