[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <cceb503f429ae829069709ac476acef77a0e8612.1730191256.git.xiaopei01@kylinos.cn>
Date: Tue, 29 Oct 2024 16:44:51 +0800
From: Pei Xiao <xiaopei01@...inos.cn>
To: jic23@...nel.org,
lars@...afoo.de,
linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: xiongxin@...inos.cn,
xiaopeitux@...mail.com,
Pei Xiao <xiaopei01@...inos.cn>
Subject: [PATCH] iio: test : rescale: check null return of kunit_kmalloc
kunit_kmalloc may fail, return might be NULL and will cause
NULL pointer dereference later.
Signed-off-by: Pei Xiao <xiaopei01@...inos.cn>
---
drivers/iio/test/iio-test-rescale.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/iio/test/iio-test-rescale.c b/drivers/iio/test/iio-test-rescale.c
index 31ee55a6faed..11bfff6636a3 100644
--- a/drivers/iio/test/iio-test-rescale.c
+++ b/drivers/iio/test/iio-test-rescale.c
@@ -652,6 +652,8 @@ static void iio_rescale_test_scale(struct kunit *test)
int rel_ppm;
int ret;
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buff);
+
rescale.numerator = t->numerator;
rescale.denominator = t->denominator;
rescale.offset = t->offset;
@@ -681,6 +683,8 @@ static void iio_rescale_test_offset(struct kunit *test)
int values[2];
int ret;
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buff_off);
+
rescale.numerator = t->numerator;
rescale.denominator = t->denominator;
rescale.offset = t->offset;
--
2.34.1
Powered by blists - more mailing lists