Skip to content

Commit b609e64

Browse files
committed
lib: packing: catch kunit_kzalloc() failure in the pack() test
JIRA: https://issues.redhat.com/browse/RHEL-92666 Upstream commit(s): commit 1405981 Author: Vladimir Oltean <vladimir.oltean@nxp.com> Date: Fri Oct 4 14:00:12 2024 +0300 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: e9502ea ("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> Signed-off-by: Petr Oros <poros@redhat.com>
1 parent 2e13b94 commit b609e64

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lib/packing_test.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ static void packing_test_pack(struct kunit *test)
375375
int err;
376376

377377
pbuf = kunit_kzalloc(test, params->pbuf_size, GFP_KERNEL);
378+
KUNIT_ASSERT_NOT_NULL(test, pbuf);
378379

379380
err = pack(pbuf, params->uval, params->start_bit, params->end_bit,
380381
params->pbuf_size, params->quirks);

0 commit comments

Comments
 (0)