kunit: debugfs: Fix unchecked dereference in debugfs_print_results()
authorRichard Fitzgerald <rf@opensource.cirrus.com>
Mon, 30 Oct 2023 10:47:58 +0000 (10:47 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jan 2024 23:35:15 +0000 (15:35 -0800)
commit5e990887803420f2d50b510bd1203d66ecb7d40a
tree418c271475a47cf8547d7a24defc4cdb7796fb18
parent335176dd8ebaca6493807dceea33c478305667fa
kunit: debugfs: Fix unchecked dereference in debugfs_print_results()

[ Upstream commit 34dfd5bb2e5507e69d9b6d6c90f546600c7a4977 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
lib/kunit/debugfs.c