Checks
Context | Check | Description |
---|---|---|
ci/checkpatch | success | coding style OK |
Commit Message
fengchengwen
March 20, 2023, 9:21 a.m. UTC
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@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/event/opdl/opdl_evdev.c | 9 +++++++++
1 file changed, 9 insertions(+)
Comments
On Mon, Mar 20, 2023 at 09:21:07AM +0000, Chengwen Feng wrote: > 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@dpdk.org > > Signed-off-by: Chengwen Feng <fengchengwen@huawei.com> Acked-by: Liang Ma <liangma@liangbit.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 >
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)