[PATCH v2 26/44] net/pfe: fix segment fault when parse devargs

Chengwen Feng fengchengwen at huawei.com
Mon Mar 20 10:20:52 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: 67fc3ff97c39 ("net/pfe: introduce basic functions")
Cc: stable at dpdk.org

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

diff --git a/drivers/net/pfe/pfe_ethdev.c b/drivers/net/pfe/pfe_ethdev.c
index 0352a57950..6e09c9443b 100644
--- a/drivers/net/pfe/pfe_ethdev.c
+++ b/drivers/net/pfe/pfe_ethdev.c
@@ -888,6 +888,9 @@ parse_integer_arg(const char *key __rte_unused,
 	char *end;
 	errno = 0;
 
+	if (value == NULL)
+		return -EINVAL;
+
 	i = strtol(value, &end, 10);
 	if (*end != 0 || errno != 0 || i < 0 || i > 1) {
 		PFE_PMD_ERR("Supported Port IDS are 0 and 1");
-- 
2.17.1



More information about the dev mailing list