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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3ed7564cf2749ee207da8ddc5ef06b54d8aea881.camel@gmail.com>
Date: Thu, 10 Apr 2025 12:09:53 +0100
From: Nuno Sá <noname.nuno@...il.com>
To: Purva Yeshi <purvayeshi550@...il.com>, lars@...afoo.de, 
	Michael.Hennerich@...log.com, jic23@...nel.org
Cc: linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] iio: adc: ad_sigma_delta: Fix use of uninitialized
 variable status_pos

Hi Purva,

Thanks for your patch... See below
On Thu, 2025-04-10 at 01:31 +0530, Purva Yeshi wrote:
> Fix Smatch-detected error:
> drivers/iio/adc/ad_sigma_delta.c:604 ad_sd_trigger_handler() error:
> uninitialized symbol 'status_pos'.
> 
> The variable `status_pos` was only initialized in specific switch cases
> (1, 2, 3, 4), which could leave it uninitialized if `reg_size` had an
> unexpected value.
> 
> Fix by validating `reg_size` before the switch block. If it’s not
> one of the expected values, return early and log an error. This ensures
> `status_pos` is always initialized before use and prevents undefined
> behavior.
> 
> Signed-off-by: Purva Yeshi <purvayeshi550@...il.com>
> ---
>  drivers/iio/adc/ad_sigma_delta.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/iio/adc/ad_sigma_delta.c
> b/drivers/iio/adc/ad_sigma_delta.c
> index 6c37f8e21120..d3b59d90b728 100644
> --- a/drivers/iio/adc/ad_sigma_delta.c
> +++ b/drivers/iio/adc/ad_sigma_delta.c
> @@ -568,6 +568,11 @@ static irqreturn_t ad_sd_trigger_handler(int irq, void
> *p)
>  	else
>  		transfer_size = reg_size;
>  
> +	if (reg_size != 1 && reg_size != 2 && reg_size != 3 && reg_size != 4)
> {
> +		dev_err(&indio_dev->dev, "Unsupported reg_size: %u\n",
> reg_size);
> +		return IRQ_HANDLED;
> +	}
> +

Use the switch case for this. Add a default branch for the invalid case. You
should also use dev_err_ratelimited() and instead of 'return IRQ_HANDLED', do
'goto irq_handled'.

Thx!
- Nuno Sá

>  	switch (reg_size) {
>  	case 4:
>  	case 2:

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ