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: 9e984bc53bc9 ("net/ice: add option to disable ACL engine in DCF")
Fixes: 7564d5509611 ("net/ice: add DCF hardware initialization")
Fixes: 603beeb970b5 ("net/ice: add safe mode devarg")
Fixes: 79d559de896b ("net/ice: add option for setting HW debug mask")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/ice/ice_dcf_ethdev.c | 6 ++++++
drivers/net/ice/ice_ethdev.c | 6 ++++++
2 files changed, 12 insertions(+)
@@ -1933,6 +1933,9 @@ static int
ice_dcf_engine_disabled_handler(__rte_unused const char *key,
const char *value, __rte_unused void *opaque)
{
+ if (value == NULL)
+ return -EINVAL;
+
if (strcmp(value, "off"))
return -1;
@@ -1943,6 +1946,9 @@ static int
ice_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;
@@ -1887,6 +1887,9 @@ parse_bool(const char *key, const char *value, void *args)
char *end;
int num;
+ if (value == NULL)
+ return -EINVAL;
+
num = strtoul(value, &end, 10);
if (num != 0 && num != 1) {
@@ -1906,6 +1909,9 @@ parse_u64(const char *key, const char *value, void *args)
u64 *num = (u64 *)args;
u64 tmp;
+ if (value == NULL)
+ return -EINVAL;
+
errno = 0;
tmp = strtoull(value, NULL, 16);
if (errno) {