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-next>] [day] [month] [year] [list]
Message-Id: <20230113133320.7531-1-abelova@astralinux.ru>
Date:   Fri, 13 Jan 2023 16:33:20 +0300
From:   Anastasia Belova <abelova@...ralinux.ru>
To:     Tomasz Duszynski <tomasz.duszynski@...akon.com>
Cc:     Anastasia Belova <abelova@...ralinux.ru>,
        Jonathan Cameron <jic23@...nel.org>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Andy Shevchenko <andy.shevchenko@...il.com>,
        linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
        lvc-project@...uxtesting.org
Subject: [PATCH] iio: chemical: scd30: Add check for NULL in scd30_i2c_command

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;
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ