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 748DD41DB5; Thu, 2 Mar 2023 08:57:08 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4C58A42D3F; Thu, 2 Mar 2023 08:56:40 +0100 (CET) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 0532D41156 for ; Thu, 2 Mar 2023 08:56:33 +0100 (CET) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4PS3Lv6HPhzrSHf; Thu, 2 Mar 2023 15:55:51 +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; Thu, 2 Mar 2023 15:56:31 +0800 From: Chengwen Feng To: , , Dongdong Liu , Yisen Zhuang , "Min Hu (Connor)" , Chengchang Tang CC: Subject: [PATCH 6/9] net/hns3: fix segment fault when parse runtime config Date: Thu, 2 Mar 2023 07:50:09 +0000 Message-ID: <20230302075012.32423-7-fengchengwen@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230302075012.32423-1-fengchengwen@huawei.com> References: <20230302075012.32423-1-fengchengwen@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.50.163.32] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) 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 input args with 'only keys' (e.g. rx_func_hint). Fixes: a124f9e9591b ("net/hns3: add runtime config to select IO burst function") Fixes: 70791213242e ("net/hns3: support masking device capability") Fixes: 2fc3e696a7f1 ("net/hns3: add runtime config for mailbox limit time") Cc: stable@dpdk.org Signed-off-by: Chengwen Feng --- drivers/net/hns3/hns3_common.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c index a0c9e66c2c..f077ef5057 100644 --- a/drivers/net/hns3/hns3_common.c +++ b/drivers/net/hns3/hns3_common.c @@ -163,6 +163,9 @@ hns3_parse_io_hint_func(const char *key, const char *value, void *extra_args) RTE_SET_USED(key); + if (value == NULL || extra_args == NULL) + return 0; + if (strcmp(value, "vec") == 0) hint = HNS3_IO_FUNC_HINT_VEC; else if (strcmp(value, "sve") == 0) @@ -203,6 +206,9 @@ hns3_parse_dev_caps_mask(const char *key, const char *value, void *extra_args) RTE_SET_USED(key); + if (value == NULL || extra_args == NULL) + return 0; + val = strtoull(value, NULL, HNS3_CONVERT_TO_HEXADECIMAL); *(uint64_t *)extra_args = val; @@ -216,6 +222,9 @@ hns3_parse_mbx_time_limit(const char *key, const char *value, void *extra_args) RTE_SET_USED(key); + if (value == NULL || extra_args == NULL) + return 0; + val = strtoul(value, NULL, HNS3_CONVERT_TO_DECIMAL); /* -- 2.17.1