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: d0b8a4e19131 ("raw/cnxk_gpio: add GPIO driver skeleton")
Fixes: ecc0dd455e9a ("raw/cnxk_gpio: add option to select subset of GPIOs")
Cc: sta...@dpdk.org

Signed-off-by: Chengwen Feng <fengcheng...@huawei.com>
---
 drivers/raw/cnxk_gpio/cnxk_gpio.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/raw/cnxk_gpio/cnxk_gpio.c 
b/drivers/raw/cnxk_gpio/cnxk_gpio.c
index e2907c18b5..5a28e307d2 100644
--- a/drivers/raw/cnxk_gpio/cnxk_gpio.c
+++ b/drivers/raw/cnxk_gpio/cnxk_gpio.c
@@ -67,6 +67,9 @@ cnxk_gpio_parse_arg_gpiochip(const char *key __rte_unused, 
const char *value,
 {
        long val;
 
+       if (value == NULL)
+               return -EINVAL;
+
        errno = 0;
        val = strtol(value, NULL, 10);
        if (errno)
@@ -81,6 +84,9 @@ static int
 cnxk_gpio_parse_arg_allowlist(const char *key __rte_unused, const char *value,
                              void *extra_args __rte_unused)
 {
+       if (value == NULL)
+               return -EINVAL;
+
        allowlist = strdup(value);
        if (!allowlist)
                return -ENOMEM;
-- 
2.17.1

Reply via email to