[PATCH v2 21/44] net/mlx4: fix segment fault when parse devargs

Chengwen Feng fengchengwen at huawei.com
Mon Mar 20 10:20:47 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'.

Fixes: 001a520e419f ("net/mlx4: add port parameter")
Cc: stable at dpdk.org

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

diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index a54016f4a2..7c11f3a129 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -521,6 +521,9 @@ mlx4_arg_parse(const char *key, const char *val, struct mlx4_conf *conf)
 {
 	unsigned long tmp;
 
+	if (val == NULL)
+		return -EINVAL;
+
 	errno = 0;
 	tmp = strtoul(val, NULL, 0);
 	if (errno) {
-- 
2.17.1



More information about the dev mailing list