mirror-linux/include/kunit
Richard Fitzgerald a7a81655dc 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 7ece381aa7 ("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>
2026-01-05 15:32:03 -07:00
..
assert.h kunit: Rename KUNIT_ASSERT_FAILURE to KUNIT_FAIL_AND_ABORT for readability 2024-07-12 10:12:05 -06:00
attributes.h kunit: Add ability to filter attributes 2023-07-26 13:29:15 -06:00
clk.h clk: test: Forward-declare struct of_phandle_args in kunit/clk.h 2025-05-06 14:50:01 -07:00
device.h kunit: Add APIs for managing devices 2023-12-18 13:28:08 -07:00
of.h of: kunit: Extract some overlay boiler plate into macros 2024-10-09 16:25:32 -07:00
platform_device.h kunit: platform: Resolve 'struct completion' warning 2025-01-11 16:00:36 -07:00
resource.h kunit: Add a macro to wrap a deferred action function 2023-12-18 13:21:14 -07:00
run-in-irq-context.h kunit: Enforce task execution in {soft,hard}irq contexts 2025-12-22 12:20:08 -08:00
skbuff.h kunit: skb: add gfp to kernel doc for kunit_zalloc_skb() 2024-11-19 14:52:17 -07:00
static_stub.h kunit: Allow passing function pointer to kunit_activate_static_stub() 2024-01-03 09:06:52 -07:00
test-bug.h
test.h kunit: Protect KUNIT_BINARY_STR_ASSERTION against ERR_PTR values 2026-01-05 15:32:03 -07:00
try-catch.h kunit: Adjust kunit_test timeout based on test_{suite,case} speed 2025-06-24 20:47:39 -06:00
visibility.h module: Convert symbol namespace to string literal 2024-12-02 11:34:44 -08:00