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]
Date:   Fri, 13 Jan 2023 21:41:40 +0300
From:   Alexey Khoroshilov <khoroshilov@...ras.ru>
To:     Anastasia Belova <abelova@...ralinux.ru>,
        Tomasz Duszynski <tomasz.duszynski@...akon.com>
Cc:     Lars-Peter Clausen <lars@...afoo.de>, lvc-project@...uxtesting.org,
        linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
        Andy Shevchenko <andy.shevchenko@...il.com>,
        Jonathan Cameron <jic23@...nel.org>
Subject: Re: [lvc-project] [PATCH] iio: chemical: scd30: Add check for NULL in
 scd30_i2c_command

On 13.01.2023 16:33, Anastasia Belova wrote:
> Check rsp for NULL-pointer before dereferencing.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: e510190e0139 ("iio: chemical: scd30: add I2C interface driver")
> Signed-off-by: Anastasia Belova <abelova@...ralinux.ru>
> ---
>  drivers/iio/chemical/scd30_i2c.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/chemical/scd30_i2c.c b/drivers/iio/chemical/scd30_i2c.c
> index bae479a4721f..84baf67fc0ce 100644
> --- a/drivers/iio/chemical/scd30_i2c.c
> +++ b/drivers/iio/chemical/scd30_i2c.c
> @@ -101,8 +101,10 @@ static int scd30_i2c_command(struct scd30_state *state, enum scd30_cmd cmd, u16
>  			return -EIO;
>  		}
>  
> -		*rsp++ = buf[i];
> -		*rsp++ = buf[i + 1];
> +		if (rsp) {
> +			*rsp++ = buf[i];
> +			*rsp++ = buf[i + 1];
> +		}
>  	}
>  
>  	return 0;
> 


It seems it is better to put the whole validation loop under if (rsp)
check.

--
Alexey

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ