[PATCH 2/9] compressdev: fix segment fault when parse input args

Chengwen Feng fengchengwen at huawei.com
Thu Mar 2 08:50:05 CET 2023


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'
(e.g. socket_id).

Fixes: ed7dd94f7f66 ("compressdev: add basic device management")
Cc: stable at dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen at huawei.com>
---
 lib/compressdev/rte_compressdev_pmd.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/compressdev/rte_compressdev_pmd.c b/lib/compressdev/rte_compressdev_pmd.c
index e139bc86e7..93c31fbac8 100644
--- a/lib/compressdev/rte_compressdev_pmd.c
+++ b/lib/compressdev/rte_compressdev_pmd.c
@@ -40,6 +40,9 @@ rte_compressdev_pmd_parse_uint_arg(const char *key __rte_unused,
 	int i;
 	char *end;
 
+	if (value == NULL || extra_args == NULL)
+		return -EINVAL;
+
 	errno = 0;
 	i = strtol(value, &end, 10);
 	if (*end != 0 || errno != 0 || i < 0)
-- 
2.17.1



More information about the dev mailing list