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: <20241018-cid1593398badshift-v1-1-11550a10ff25@gmail.com>
Date: Fri, 18 Oct 2024 18:54:42 +0000
From: Karan Sanghavi <karansanghvi98@...il.com>
To: Tomasz Duszynski <tduszyns@...il.com>, 
 Jonathan Cameron <jic23@...nel.org>, Lars-Peter Clausen <lars@...afoo.de>
Cc: linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org, 
 Shuah Khan <skhan@...uxfoundation.org>, 
 Karan Sanghavi <karansanghavi98@...il.com>, 
 Karan Sanghavi <karansanghvi98@...il.com>
Subject: [PATCH] iio: chemical: sps30: Add Null pointer check

Add a Null pointer check before assigning and incrementing
the null pointer

Signed-off-by: Karan Sanghavi <karansanghvi98@...il.com>
---
 drivers/iio/chemical/sps30_i2c.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/iio/chemical/sps30_i2c.c b/drivers/iio/chemical/sps30_i2c.c
index 1b21b6bcd0e7..d2142e4c748c 100644
--- a/drivers/iio/chemical/sps30_i2c.c
+++ b/drivers/iio/chemical/sps30_i2c.c
@@ -105,16 +105,18 @@ static int sps30_i2c_command(struct sps30_state *state, u16 cmd, void *arg, size
 		return ret;
 
 	/* validate received data and strip off crc bytes */
-	tmp = rsp;
-	for (i = 0; i < rsp_size; i += 3) {
-		crc = crc8(sps30_i2c_crc8_table, buf + i, 2, CRC8_INIT_VALUE);
-		if (crc != buf[i + 2]) {
-			dev_err(state->dev, "data integrity check failed\n");
-			return -EIO;
+	if (rsp) {
+		tmp = rsp;
+		for (i = 0; i < rsp_size; i += 3) {
+			crc = crc8(sps30_i2c_crc8_table, buf + i, 2, CRC8_INIT_VALUE);
+			if (crc != buf[i + 2]) {
+				dev_err(state->dev, "data integrity check failed\n");
+				return -EIO;
+			}
+
+			*tmp++ = buf[i];
+			*tmp++ = buf[i + 1];
 		}
-
-		*tmp++ = buf[i];
-		*tmp++ = buf[i + 1];
 	}
 
 	return 0;

---
base-commit: f2493655d2d3d5c6958ed996b043c821c23ae8d3
change-id: 20241018-cid1593398badshift-9c512a3b92d9

Best regards,
-- 
Karan Sanghavi <karansanghvi98@...il.com>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ