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] [day] [month] [year] [list]
Message-ID: <20211228183925.059884e1@jic23-huawei>
Date:   Tue, 28 Dec 2021 18:39:25 +0000
From:   Jonathan Cameron <jic23@...nel.org>
To:     trix@...hat.com
Cc:     jacopo@...ndi.org, lars@...afoo.de, nathan@...nel.org,
        ndesaulniers@...gle.com, linux-iio@...r.kernel.org,
        linux-kernel@...r.kernel.org, llvm@...ts.linux.dev
Subject: Re: [PATCH] iio: chemical: set val parameter only on success

On Fri, 24 Dec 2021 07:08:33 -0800
trix@...hat.com wrote:

> From: Tom Rix <trix@...hat.com>
> 
> Clang static analysis reports this representative warning
> 
> sunrise_co2.c:410:9: warning: Assigned value is garbage or undefined
>   *val = value;
>        ^ ~~~~~
> 
> The ealier call to sunrise_read_word can fail without setting
> value.  So defer setting val until we know the read was successful.
> 
> Fixes: c397894e24f1 ("iio: chemical: Add Senseair Sunrise 006-0-007 driver")
> Signed-off-by: Tom Rix <trix@...hat.com>
Hi Tom,

This won't have any actual affect as if the read_raw callback returns a negative
error code we won't use the value.  However, good to clean it up so applied
to the togreg branch of iio.git.

Thanks,

Jonathan
> ---
>  drivers/iio/chemical/sunrise_co2.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/chemical/sunrise_co2.c b/drivers/iio/chemical/sunrise_co2.c
> index 233bd0f379c93..8440dc0c77cfe 100644
> --- a/drivers/iio/chemical/sunrise_co2.c
> +++ b/drivers/iio/chemical/sunrise_co2.c
> @@ -407,24 +407,24 @@ static int sunrise_read_raw(struct iio_dev *iio_dev,
>  			mutex_lock(&sunrise->lock);
>  			ret = sunrise_read_word(sunrise, SUNRISE_CO2_FILTERED_COMP_REG,
>  						&value);
> -			*val = value;
>  			mutex_unlock(&sunrise->lock);
>  
>  			if (ret)
>  				return ret;
>  
> +			*val = value;
>  			return IIO_VAL_INT;
>  
>  		case IIO_TEMP:
>  			mutex_lock(&sunrise->lock);
>  			ret = sunrise_read_word(sunrise, SUNRISE_CHIP_TEMPERATURE_REG,
>  						&value);
> -			*val = value;
>  			mutex_unlock(&sunrise->lock);
>  
>  			if (ret)
>  				return ret;
>  
> +			*val = value;
>  			return IIO_VAL_INT;
>  
>  		default:

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ