]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
kunit: Fix potential null dereference in kunit_device_driver_test()
authorZichen Xie <zichenxie0106@gmail.com>
Fri, 15 Nov 2024 05:43:36 +0000 (23:43 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 9 Dec 2024 09:41:00 +0000 (10:41 +0100)
commit5d28fac59369b5d3c48cdf09e50275a61ff91202
tree6414330245292a7b140d65d194a1858353262daa
parentb544be374458009b65d16296291fbd6fbb824ba6
kunit: Fix potential null dereference in kunit_device_driver_test()

commit 435c20eed572a95709b1536ff78832836b2f91b1 upstream.

kunit_kzalloc() may return a NULL pointer, dereferencing it without
NULL check may lead to NULL dereference.
Add a NULL check for test_state.

Link: https://lore.kernel.org/r/20241115054335.21673-1-zichenxie0106@gmail.com
Fixes: d03c720e03bd ("kunit: Add APIs for managing devices")
Signed-off-by: Zichen Xie <zichenxie0106@gmail.com>
Cc: stable@vger.kernel.org
Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
lib/kunit/kunit-test.c