From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5AFF7427E0; Mon, 20 Mar 2023 10:28:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3B84642B8E; Mon, 20 Mar 2023 10:28:05 +0100 (CET) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 0DB17427E9 for ; Mon, 20 Mar 2023 10:28:03 +0100 (CET) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Pg8T30h5kzSmnX; Mon, 20 Mar 2023 17:24:39 +0800 (CST) Received: from localhost.localdomain (10.50.163.32) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Mon, 20 Mar 2023 17:28:01 +0800 From: Chengwen Feng To: , , Andrew Rybchenko CC: Subject: [PATCH v2 02/44] ethdev: fix segment fault when parse args Date: Mon, 20 Mar 2023 09:20:28 +0000 Message-ID: <20230320092110.37295-3-fengchengwen@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230320092110.37295-1-fengchengwen@huawei.com> References: <20230314124813.39521-1-fengchengwen@huawei.com> <20230320092110.37295-1-fengchengwen@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.50.163.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500024.china.huawei.com (7.185.36.10) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 args with 'only keys' (e.g. 'mac,representor'). Fixes: c10cdce180a6 ("ethdev: support MAC address as iterator filter") Fixes: a7d3c6271d55 ("ethdev: support representor id as iterator filter") Cc: stable@dpdk.org Signed-off-by: Chengwen Feng --- lib/ethdev/rte_class_eth.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ethdev/rte_class_eth.c b/lib/ethdev/rte_class_eth.c index b61dae849d..b9fc25348b 100644 --- a/lib/ethdev/rte_class_eth.c +++ b/lib/ethdev/rte_class_eth.c @@ -46,6 +46,9 @@ eth_mac_cmp(const char *key __rte_unused, struct rte_eth_dev_info dev_info; uint32_t index; + if (value == NULL) + return -EINVAL; + /* Parse devargs MAC address. */ if (rte_ether_unformat_addr(value, &mac) < 0) return -1; /* invalid devargs value */ @@ -72,6 +75,9 @@ eth_representor_cmp(const char *key __rte_unused, if ((data->dev_flags & RTE_ETH_DEV_REPRESENTOR) == 0) return -1; /* not a representor port */ + if (value == NULL) + return -EINVAL; + /* Parse devargs representor values. */ values = strdup(value); if (values == NULL) -- 2.17.1