[v2,18/44] net/idpf: fix segment fault when parse devargs

Message ID 20230320092110.37295-19-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: 549343c25db8 ("net/idpf: support device initialization")
Cc: stable@dpdk.org

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

Patch

diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c
index 46aec6ae37..105dcc8744 100644
--- a/drivers/net/idpf/idpf_ethdev.c
+++ b/drivers/net/idpf/idpf_ethdev.c
@@ -903,6 +903,9 @@  parse_vport(const char *key, const char *value, void *args)
 	struct idpf_devargs *devargs = args;
 	const char *pos = value;
 
+	if (value == NULL)
+		return -EINVAL;
+
 	devargs->req_vport_nb = 0;
 
 	if (*pos == '[')
@@ -936,6 +939,9 @@  parse_bool(const char *key, const char *value, void *args)
 	char *end;
 	int num;
 
+	if (value == NULL)
+		return -EINVAL;
+
 	errno = 0;
 
 	num = strtoul(value, &end, 10);