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: b14e8a57b9fe ("net/iavf: support quanta size configuration")
Fixes: 4cce7422dd38 ("net/iavf: stop PCI probe in DCF mode")
Cc: sta...@dpdk.org

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

diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 3196210f2c..654741b71f 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -2185,6 +2185,9 @@ parse_u16(__rte_unused const char *key, const char 
*value, void *args)
        u16 *num = (u16 *)args;
        u16 tmp;
 
+       if (value == NULL)
+               return -EINVAL;
+
        errno = 0;
        tmp = strtoull(value, NULL, 10);
        if (errno || !tmp) {
@@ -2815,6 +2818,9 @@ static int
 iavf_dcf_cap_check_handler(__rte_unused const char *key,
                           const char *value, __rte_unused void *opaque)
 {
+       if (value == NULL)
+               return -EINVAL;
+
        if (strcmp(value, "dcf"))
                return -1;
 
-- 
2.17.1

Reply via email to