[PATCH v2 29/44] bus/pci: fix segment fault when parse args

Chengwen Feng fengchengwen at huawei.com
Mon Mar 20 10:20:55 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: 4410c1b0c0a2 ("bus/pci: add iteration filter on address")
Cc: stable at dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen at huawei.com>
---
 drivers/bus/pci/pci_params.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/bus/pci/pci_params.c b/drivers/bus/pci/pci_params.c
index d24cc201b8..b8bee6a6c1 100644
--- a/drivers/bus/pci/pci_params.c
+++ b/drivers/bus/pci/pci_params.c
@@ -34,6 +34,8 @@ pci_addr_kv_cmp(const char *key __rte_unused,
 	struct rte_pci_addr *addr1 = &_addr1;
 	struct rte_pci_addr *addr2 = _addr2;
 
+	if (value == NULL)
+		return -EINVAL;
 	if (rte_pci_addr_parse(value, addr1))
 		return -1;
 	return -abs(rte_pci_addr_cmp(addr1, addr2));
-- 
2.17.1



More information about the dev mailing list