]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
kunit: Protect KUNIT_BINARY_STR_ASSERTION against ERR_PTR values
authorRichard Fitzgerald <rf@opensource.cirrus.com>
Fri, 19 Dec 2025 16:12:12 +0000 (16:12 +0000)
committerShuah Khan <skhan@linuxfoundation.org>
Mon, 5 Jan 2026 22:32:03 +0000 (15:32 -0700)
commita7a81655dc90688f9ddff1c0b185d7a6fa8bfc7d
tree1096de01e3ed4b477078e52a03abf6f444de1849
parent90b5f2dce9d919a4e37abf29598d23c7f20108ba
kunit: Protect KUNIT_BINARY_STR_ASSERTION against ERR_PTR values

Replace the NULL checks with IS_ERR_OR_NULL() in
KUNIT_BINARY_STR_ASSERTION() to prevent the strcmp() faulting if a
passed pointer is an ERR_PTR.

Commit 7ece381aa72d4 ("kunit: Protect string comparisons against NULL")
added the checks for NULL on both pointers so that asserts would fail,
instead of faulting, if either pointer is NULL. But either pointer
could hold an ERR_PTR value.

This assumes that the assertion is expecting both strings to be valid,
and is asserting the equality of their _content_.

Link: https://lore.kernel.org/r/20251219161212.1648076-1-rf@opensource.cirrus.com
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
include/kunit/test.h