All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anastasia Belova <abelova@astralinux.ru>
To: Tomasz Duszynski <tomasz.duszynski@octakon.com>
Cc: Anastasia Belova <abelova@astralinux.ru>,
	Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	lvc-project@linuxtesting.org
Subject: [PATCH] iio: chemical: scd30: Add check for NULL in scd30_i2c_command
Date: Fri, 13 Jan 2023 16:33:20 +0300	[thread overview]
Message-ID: <20230113133320.7531-1-abelova@astralinux.ru> (raw)

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


             reply	other threads:[~2023-01-13 13:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-13 13:33 Anastasia Belova [this message]
2023-01-13 14:03 ` [PATCH] iio: chemical: scd30: Add check for NULL in scd30_i2c_command 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230113133320.7531-1-abelova@astralinux.ru \
    --to=abelova@astralinux.ru \
    --cc=andy.shevchenko@gmail.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=tomasz.duszynski@octakon.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.