mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iio: chemical: scd30: Add check for NULL in scd30_i2c_command
@ 2023-01-13 13:33 Anastasia Belova
  2023-01-13 14:03 ` Andy Shevchenko
  2023-01-13 18:41 ` [lvc-project] " Alexey Khoroshilov
  0 siblings, 2 replies; 6+ messages in thread
From: Anastasia Belova @ 2023-01-13 13:33 UTC (permalink / raw)
  To: Tomasz Duszynski
  Cc: Anastasia Belova, Jonathan Cameron, Lars-Peter Clausen,
	Andy Shevchenko, linux-iio, linux-kernel, lvc-project

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@astralinux.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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-01-13 21:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-13 13:33 [PATCH] iio: chemical: scd30: Add check for NULL in scd30_i2c_command Anastasia Belova
2023-01-13 14:03 ` Andy Shevchenko
2023-01-13 18:41 ` [lvc-project] " Alexey Khoroshilov
2023-01-13 18:47   ` Andy Shevchenko
2023-01-13 19:27     ` Alexey Khoroshilov
2023-01-13 21:00       ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®