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: 38c2e3240ba8 ("event/cnxk: add option to control SSO HWGRP QoS")
Fixes: 20345cbda6d3 ("event/cnxk: support WQE stashing")
Fixes: 1b06a817b835 ("event/cnxk: add option to disable NPA")
Fixes: e656d40fd12f ("event/cnxk: add option for in-flight buffer count")
Fixes: 8a3d58c189fd ("event/cnxk: add option to control timer adapters")
Fixes: 8bdbae66b299 ("event/cnxk: add external clock support for timer")
Cc: sta...@dpdk.org

Signed-off-by: Chengwen Feng <fengcheng...@huawei.com>
---
 drivers/event/cnxk/cnxk_eventdev.c  | 6 ++++++
 drivers/event/cnxk/cnxk_eventdev.h  | 6 ++++++
 drivers/event/cnxk/cnxk_tim_evdev.c | 6 ++++++
 3 files changed, 18 insertions(+)

diff --git a/drivers/event/cnxk/cnxk_eventdev.c 
b/drivers/event/cnxk/cnxk_eventdev.c
index cb9ba5d353..970681adfc 100644
--- a/drivers/event/cnxk/cnxk_eventdev.c
+++ b/drivers/event/cnxk/cnxk_eventdev.c
@@ -565,6 +565,9 @@ parse_sso_kvargs_qos_dict(const char *key, const char 
*value, void *opaque)
 {
        RTE_SET_USED(key);
 
+       if (value == NULL)
+               return -EINVAL;
+
        /* Dict format [Qx-TAQ-IAQ][Qz-TAQ-IAQ] use '-' cause ',' isn't allowed.
         * Everything is expressed in percentages, 0 represents default.
         */
@@ -578,6 +581,9 @@ parse_sso_kvargs_stash_dict(const char *key, const char 
*value, void *opaque)
 {
        RTE_SET_USED(key);
 
+       if (value == NULL)
+               return -EINVAL;
+
        /* Dict format [Qx|<stash_offset>|<stash_length>] use '|' cause ','
         * isn't allowed.
         */
diff --git a/drivers/event/cnxk/cnxk_eventdev.h 
b/drivers/event/cnxk/cnxk_eventdev.h
index c7cbd722ab..acd705183c 100644
--- a/drivers/event/cnxk/cnxk_eventdev.h
+++ b/drivers/event/cnxk/cnxk_eventdev.h
@@ -169,6 +169,9 @@ parse_kvargs_flag(const char *key, const char *value, void 
*opaque)
 {
        RTE_SET_USED(key);
 
+       if (value == NULL)
+               return -EINVAL;
+
        *(uint8_t *)opaque = !!atoi(value);
        return 0;
 }
@@ -178,6 +181,9 @@ parse_kvargs_value(const char *key, const char *value, void 
*opaque)
 {
        RTE_SET_USED(key);
 
+       if (value == NULL)
+               return -EINVAL;
+
        *(uint32_t *)opaque = (uint32_t)atoi(value);
        return 0;
 }
diff --git a/drivers/event/cnxk/cnxk_tim_evdev.c 
b/drivers/event/cnxk/cnxk_tim_evdev.c
index 121480df15..e5450fd9bf 100644
--- a/drivers/event/cnxk/cnxk_tim_evdev.c
+++ b/drivers/event/cnxk/cnxk_tim_evdev.c
@@ -490,6 +490,9 @@ cnxk_tim_parse_kvargs_dict(const char *key, const char 
*value, void *opaque)
 {
        RTE_SET_USED(key);
 
+       if (value == NULL)
+               return -EINVAL;
+
        /* Dict format [ring-chunk_sz-disable_npa-enable_stats] use '-' as ','
         * isn't allowed. 0 represents default.
         */
@@ -528,6 +531,9 @@ cnxk_tim_parse_kvargs_dsv(const char *key, const char 
*value, void *opaque)
 {
        RTE_SET_USED(key);
 
+       if (value == NULL)
+               return -EINVAL;
+
        /* DSV format GPIO-PTP-SYNCE-BTS use '-' as ','
         * isn't allowed. 0 represents default.
         */
-- 
2.17.1

Reply via email to