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

Configure Feed

Select the types of activity you want to include in your feed.

kunit: debugfs: Fix unchecked dereference in debugfs_print_results()

Move the call to kunit_suite_has_succeeded() after the check that
the kunit_suite pointer is valid.

This was found by smatch:

lib/kunit/debugfs.c:66 debugfs_print_results() warn: variable
dereferenced before check 'suite' (see line 63)

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Fixes: 38289a26e1b8 ("kunit: fix debugfs code to use enum kunit_status, not bool")
Reviewed-by: Rae Moar <rmoar@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Richard Fitzgerald and committed by
Shuah Khan
34dfd5bb 15bf0000

+3 -1
+3 -1
lib/kunit/debugfs.c
··· 60 60 static int debugfs_print_results(struct seq_file *seq, void *v) 61 61 { 62 62 struct kunit_suite *suite = (struct kunit_suite *)seq->private; 63 - enum kunit_status success = kunit_suite_has_succeeded(suite); 63 + enum kunit_status success; 64 64 struct kunit_case *test_case; 65 65 66 66 if (!suite) 67 67 return 0; 68 + 69 + success = kunit_suite_has_succeeded(suite); 68 70 69 71 /* Print KTAP header so the debugfs log can be parsed as valid KTAP. */ 70 72 seq_puts(seq, "KTAP version 1\n");