From: Richard Fitzgerald Date: Mon, 18 Dec 2023 15:17:29 +0000 (+0000) Subject: kunit: Fix NULL-dereference in kunit_init_suite() if suite->log is NULL X-Git-Tag: v6.8-rc1~160^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a0b84213f947176ddcd0e96e0751a109f28cde21;p=thirdparty%2Fkernel%2Flinux.git kunit: Fix NULL-dereference in kunit_init_suite() if suite->log is NULL suite->log must be checked for NULL before passing it to string_stream_clear(). This was done in kunit_init_test() but was missing from kunit_init_suite(). Signed-off-by: Richard Fitzgerald Fixes: 6d696c4695c5 ("kunit: add ability to run tests after boot using debugfs") Reviewed-by: Rae Moar Acked-by: David Gow Reviewed-by: Muhammad Usama Anjum Signed-off-by: Shuah Khan --- diff --git a/lib/kunit/test.c b/lib/kunit/test.c index 3a3d4ebb35dbe..f95d2093a0aa3 100644 --- a/lib/kunit/test.c +++ b/lib/kunit/test.c @@ -697,7 +697,9 @@ static void kunit_init_suite(struct kunit_suite *suite) kunit_debugfs_create_suite(suite); suite->status_comment[0] = '\0'; suite->suite_init_err = 0; - string_stream_clear(suite->log); + + if (suite->log) + string_stream_clear(suite->log); } bool kunit_enabled(void)