]> www.infradead.org Git - users/dwmw2/linux.git/commit
lib: packing: catch kunit_kzalloc() failure in the pack() test
authorVladimir Oltean <vladimir.oltean@nxp.com>
Fri, 4 Oct 2024 11:00:12 +0000 (14:00 +0300)
committerJakub Kicinski <kuba@kernel.org>
Mon, 7 Oct 2024 23:36:25 +0000 (16:36 -0700)
commit1405981bbba0796530311d07a67bf58228cc0fcc
tree5da8c8856a20599ad00c7fb69018b5705933be77
parentbec2a32145d5cc066df29182fa0e5b0d4329b1a1
lib: packing: catch kunit_kzalloc() failure in the pack() test

kunit_kzalloc() may fail. Other call sites verify that this is the case,
either using a direct comparison with the NULL pointer, or the
KUNIT_ASSERT_NOT_NULL() or KUNIT_ASSERT_NOT_ERR_OR_NULL().

Pick KUNIT_ASSERT_NOT_NULL() as the error handling method that made most
sense to me. It's an unlikely thing to happen, but at least we call
__kunit_abort() instead of dereferencing this NULL pointer.

Fixes: e9502ea6db8a ("lib: packing: add KUnit tests adapted from selftests")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Link: https://patch.msgid.link/20241004110012.1323427-1-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
lib/packing_test.c