[PATCH v2 05/44] net/ring: fix segment fault when parse devargs

Chengwen Feng fengchengwen at huawei.com
Mon Mar 20 10:20:31 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: 61934c0956d4 ("ring: convert to use of PMD_REGISTER_DRIVER and fix linking")
Fixes: 96cb19521147 ("net/ring: use EAL APIs in PMD specific API")
Cc: stable at dpdk.org

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

diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c
index e8bc9b6271..88b19e205e 100644
--- a/drivers/net/ring/rte_eth_ring.c
+++ b/drivers/net/ring/rte_eth_ring.c
@@ -562,6 +562,9 @@ static int parse_kvlist(const char *key __rte_unused,
 	char *node;
 	char *end;
 
+	if (value == NULL)
+		return -EINVAL;
+
 	name = strdup(value);
 
 	ret = -EINVAL;
@@ -630,6 +633,9 @@ parse_internal_args(const char *key __rte_unused, const char *value,
 	void *args;
 	int ret, n;
 
+	if (value == NULL)
+		return -EINVAL;
+
 	/* make sure 'value' is valid pointer length */
 	if (strnlen(value, ETH_RING_INTERNAL_ARG_MAX_LEN) >=
 			ETH_RING_INTERNAL_ARG_MAX_LEN) {
-- 
2.17.1



More information about the dev mailing list