Skip to content

Commit aaa90d0

Browse files
Pei Xiaojic23
authored andcommitted
iio: test : check null return of kunit_kmalloc in iio_rescale_test_scale
kunit_kmalloc may fail, return value might be NULL and will cause NULL pointer dereference.Add KUNIT_ASSERT_NOT_ERR_OR_NULL fix it. Signed-off-by: Pei Xiao <[email protected]> Fixes: 8e74a48 ("iio: test: add basic tests for the iio-rescale driver") Link: https://patch.msgid.link/ecd56a85e54a96c2f0313c114075a21a76071ea2.1730259869.git.xiaopei01@kylinos.cn Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 4be339a commit aaa90d0

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/iio/test/iio-test-rescale.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,8 @@ static void iio_rescale_test_scale(struct kunit *test)
652652
int rel_ppm;
653653
int ret;
654654

655+
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buff);
656+
655657
rescale.numerator = t->numerator;
656658
rescale.denominator = t->denominator;
657659
rescale.offset = t->offset;
@@ -681,6 +683,8 @@ static void iio_rescale_test_offset(struct kunit *test)
681683
int values[2];
682684
int ret;
683685

686+
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buff_off);
687+
684688
rescale.numerator = t->numerator;
685689
rescale.denominator = t->denominator;
686690
rescale.offset = t->offset;

0 commit comments

Comments
 (0)