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: <20250330185608.20a4899a@jic23-huawei>
Date: Sun, 30 Mar 2025 18:56:08 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: David Lechner <dlechner@...libre.com>
Cc: linux-iio@...r.kernel.org, Michael Hennerich
 <Michael.Hennerich@...log.com>, Angelo Dureghello
 <adureghello@...libre.com>, Alexandru Ardelean <aardelean@...libre.com>,
 Beniamin Bia <beniamin.bia@...log.com>, Stefan Popa
 <stefan.popa@...log.com>, linux-kernel@...r.kernel.org, Nuno
 Sá <nuno.sa@...log.com>
Subject: Re: [PATCH v2 01/10] iio: adc: ad7606: check for NULL before
 calling sw_mode_config()

On Tue, 18 Mar 2025 17:52:09 -0500
David Lechner <dlechner@...libre.com> wrote:

> Check that the sw_mode_config function pointer is not NULL before
> calling it. Not all buses define this callback, which resulted in a NULL
> pointer dereference.
> 
> Fixes: e571c1902116 ("iio: adc: ad7606: move scale_setup as function pointer on chip-info")
> Reviewed-by: Nuno Sá <nuno.sa@...log.com>
> Signed-off-by: David Lechner <dlechner@...libre.com>
Applied to my temporary fixes-togreg-testing branch. I'll rebase that once
Greg's pull request has been taken by Linus.

> ---
>  drivers/iio/adc/ad7606.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
> index 1a314fddd7eb987b52016ce7242b446677f66427..703556eb7257ea0647135c4b268a8ead93115c6f 100644
> --- a/drivers/iio/adc/ad7606.c
> +++ b/drivers/iio/adc/ad7606.c
> @@ -1236,9 +1236,11 @@ static int ad7616_sw_mode_setup(struct iio_dev *indio_dev)
>  	st->write_scale = ad7616_write_scale_sw;
>  	st->write_os = &ad7616_write_os_sw;
>  
> -	ret = st->bops->sw_mode_config(indio_dev);
> -	if (ret)
> -		return ret;
> +	if (st->bops->sw_mode_config) {
> +		ret = st->bops->sw_mode_config(indio_dev);
> +		if (ret)
> +			return ret;
> +	}
>  
>  	/* Activate Burst mode and SEQEN MODE */
>  	return ad7606_write_mask(st, AD7616_CONFIGURATION_REGISTER,
> @@ -1268,6 +1270,9 @@ static int ad7606b_sw_mode_setup(struct iio_dev *indio_dev)
>  	st->write_scale = ad7606_write_scale_sw;
>  	st->write_os = &ad7606_write_os_sw;
>  
> +	if (!st->bops->sw_mode_config)
> +		return 0;
> +
>  	return st->bops->sw_mode_config(indio_dev);
>  }
>  
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ