The rte_kvargs_process() was used to parse KV pairs, it also supports
to parse 'only keys' (e.g. socket_id) type. And the callback function
parameter 'value' is NULL when parsed 'only keys'.
This patch fixes segment fault when parse input args with 'only keys'.
Fixes: f1debd77efaf ("net/af_xdp: introduce AF_XDP PMD")
Fixes: 288a85aef192 ("net/af_xdp: enable custom XDP program loading")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/af_xdp/rte_eth_af_xdp.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
@@ -1897,6 +1897,9 @@ parse_budget_arg(const char *key __rte_unused,
int *i = (int *)extra_args;
char *end;
+ if (value == NULL)
+ return -EINVAL;
+
*i = strtol(value, &end, 10);
if (*i < 0 || *i > UINT16_MAX) {
AF_XDP_LOG(ERR, "Invalid busy_budget %i, must be >= 0 and <= %u\n",
@@ -1915,6 +1918,9 @@ parse_integer_arg(const char *key __rte_unused,
int *i = (int *)extra_args;
char *end;
+ if (value == NULL)
+ return -EINVAL;
+
*i = strtol(value, &end, 10);
if (*i < 0) {
AF_XDP_LOG(ERR, "Argument has to be positive.\n");
@@ -1931,6 +1937,9 @@ parse_name_arg(const char *key __rte_unused,
{
char *name = extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
if (strnlen(value, IFNAMSIZ) > IFNAMSIZ - 1) {
AF_XDP_LOG(ERR, "Invalid name %s, should be less than %u bytes.\n",
value, IFNAMSIZ);
@@ -1949,6 +1958,9 @@ parse_prog_arg(const char *key __rte_unused,
{
char *path = extra_args;
+ if (value == NULL)
+ return -EINVAL;
+
if (strnlen(value, PATH_MAX) == PATH_MAX) {
AF_XDP_LOG(ERR, "Invalid path %s, should be less than %u bytes.\n",
value, PATH_MAX);