From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Jacob Keller <jacob.e.keller@intel.com>,
Przemek Kitszel <przemyslaw.kitszel@intel.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH net-next] lib: packing: catch kunit_kzalloc() failure in the pack() test
Date: Fri, 4 Oct 2024 14:00:12 +0300 [thread overview]
Message-ID: <20241004110012.1323427-1-vladimir.oltean@nxp.com> (raw)
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>
---
lib/packing_test.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/packing_test.c b/lib/packing_test.c
index 015ad1180d23..b38ea43c03fd 100644
--- a/lib/packing_test.c
+++ b/lib/packing_test.c
@@ -375,6 +375,7 @@ static void packing_test_pack(struct kunit *test)
int err;
pbuf = kunit_kzalloc(test, params->pbuf_size, GFP_KERNEL);
+ KUNIT_ASSERT_NOT_NULL(test, pbuf);
err = pack(pbuf, params->uval, params->start_bit, params->end_bit,
params->pbuf_size, params->quirks);
--
2.43.0
next reply other threads:[~2024-10-04 11:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-04 11:00 Vladimir Oltean [this message]
2024-10-04 19:20 ` Keller, Jacob E
2024-10-09 10:21 ` Przemek Kitszel
2024-10-09 20:52 ` Keller, Jacob E
2024-10-07 23:40 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241004110012.1323427-1-vladimir.oltean@nxp.com \
--to=vladimir.oltean@nxp.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jacob.e.keller@intel.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®