From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH 2/4] kvargs: harden rte_kvargs_parse
Date: Mon, 5 Oct 2026 09:53:48 -0700 [thread overview]
Message-ID: <20261005165512.334085-3-stephen@networkplumber.org> (raw)
In-Reply-To: <20261005165512.334085-1-stephen@networkplumber.org>
Make rte_kvargs_parse(NULL, ...) return an empty list rather than crash.
NULL is not excluded by the API doc, and an empty list matches
"no arguments" so safer.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/kvargs/rte_kvargs.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lib/kvargs/rte_kvargs.c b/lib/kvargs/rte_kvargs.c
index 4e3198b33f..89c1b74308 100644
--- a/lib/kvargs/rte_kvargs.c
+++ b/lib/kvargs/rte_kvargs.c
@@ -272,6 +272,10 @@ rte_kvargs_parse(const char *args, const char * const valid_keys[])
return NULL;
memset(kvlist, 0, sizeof(*kvlist));
+ /* Treat NULL as empty string */
+ if (args == NULL)
+ return kvlist;
+
if (rte_kvargs_tokenize(kvlist, args) < 0) {
rte_kvargs_free(kvlist);
return NULL;
@@ -294,7 +298,7 @@ rte_kvargs_parse_delim(const char *args, const char * const valid_keys[],
char *copy;
size_t len;
- if (valid_ends == NULL)
+ if (args == NULL || valid_ends == NULL)
return rte_kvargs_parse(args, valid_keys);
copy = strdup(args);
--
2.53.0
next prev parent reply other threads:[~2026-10-05 16:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-05 16:53 [PATCH 0/4] fix crash on device args with no driver options Stephen Hemminger
2026-10-05 16:53 ` [PATCH 1/4] devargs: fix NULL args with global device syntax Stephen Hemminger
2026-10-05 16:53 ` Stephen Hemminger [this message]
2026-10-05 16:53 ` [PATCH 3/4] test/devargs: use unit test suite runner Stephen Hemminger
2026-10-05 16:53 ` [PATCH 4/4] test/devargs: add tests for missing device arguments Stephen Hemminger
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=20261005165512.334085-3-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
/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