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: 67fc3ff97c39 ("net/pfe: introduce basic functions")
Cc: sta...@dpdk.org

Signed-off-by: Chengwen Feng <fengcheng...@huawei.com>
---
 drivers/net/pfe/pfe_ethdev.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/pfe/pfe_ethdev.c b/drivers/net/pfe/pfe_ethdev.c
index 0352a57950..6e09c9443b 100644
--- a/drivers/net/pfe/pfe_ethdev.c
+++ b/drivers/net/pfe/pfe_ethdev.c
@@ -888,6 +888,9 @@ parse_integer_arg(const char *key __rte_unused,
        char *end;
        errno = 0;
 
+       if (value == NULL)
+               return -EINVAL;
+
        i = strtol(value, &end, 10);
        if (*end != 0 || errno != 0 || i < 0 || i > 1) {
                PFE_PMD_ERR("Supported Port IDS are 0 and 1");
-- 
2.17.1

Reply via email to