[PATCH v2 41/44] event/opdl: fix segment fault when parse devargs
Chengwen Feng
fengchengwen at huawei.com
Mon Mar 20 10:21:07 CET 2023
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: 3c7f3dcfb099 ("event/opdl: add PMD main body and helper function")
Cc: stable at dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen at huawei.com>
---
drivers/event/opdl/opdl_evdev.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/event/opdl/opdl_evdev.c b/drivers/event/opdl/opdl_evdev.c
index 9ce8b39b60..f90d31aa19 100644
--- a/drivers/event/opdl/opdl_evdev.c
+++ b/drivers/event/opdl/opdl_evdev.c
@@ -580,6 +580,8 @@ static int
assign_numa_node(const char *key __rte_unused, const char *value, void *opaque)
{
int *socket_id = opaque;
+ if (value == NULL)
+ return -EINVAL;
*socket_id = atoi(value);
if (*socket_id >= RTE_MAX_NUMA_NODES)
return -1;
@@ -590,6 +592,10 @@ static int
set_do_validation(const char *key __rte_unused, const char *value, void *opaque)
{
int *do_val = opaque;
+
+ if (value == NULL)
+ return -EINVAL;
+
*do_val = atoi(value);
if (*do_val != 0)
*do_val = 1;
@@ -601,6 +607,9 @@ set_do_test(const char *key __rte_unused, const char *value, void *opaque)
{
int *do_test = opaque;
+ if (value == NULL)
+ return -EINVAL;
+
*do_test = atoi(value);
if (*do_test != 0)
--
2.17.1
More information about the dev
mailing list