Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <rf@opensource.cirrus.com>
Fixes: 6d696c4695c5 ("kunit: add ability to run tests after boot using debugfs")
Reviewed-by: Rae Moar <rmoar@google.com>
Acked-by: David Gow <davidgow@google.com>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Richard Fitzgerald and committed by
Shuah Khan
a0b84213 342fb978

+3 -1
+3 -1
lib/kunit/test.c
··· 697 697 kunit_debugfs_create_suite(suite); 698 698 suite->status_comment[0] = '\0'; 699 699 suite->suite_init_err = 0; 700 - string_stream_clear(suite->log); 700 + 701 + if (suite->log) 702 + string_stream_clear(suite->log); 701 703 } 702 704 703 705 bool kunit_enabled(void)