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

Message ID 20230320092110.37295-22-fengchengwen@huawei.com (mailing list archive)
State Changes Requested, archived
Delegated to: Thomas Monjalon
Headers
Series fix segment fault when parse args |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

fengchengwen March 20, 2023, 9:20 a.m. UTC
  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@dpdk.org

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

Patch

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) {