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 AC864427E0; Mon, 20 Mar 2023 10:31:54 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D89ED42FA8; Mon, 20 Mar 2023 10:28:57 +0100 (CET) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 272C142D3B for ; Mon, 20 Mar 2023 10:28:15 +0100 (CET) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Pg8VZ3DHCzKsJT; Mon, 20 Mar 2023 17:25:58 +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:13 +0800 From: Chengwen Feng To: , , Pavan Nikhilesh , Shijith Thotton CC: Subject: [PATCH v2 37/44] event/cnxk: fix segment fault when parse devargs Date: Mon, 20 Mar 2023 09:21:03 +0000 Message-ID: <20230320092110.37295-38-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 input args with 'only keys'. Fixes: 38c2e3240ba8 ("event/cnxk: add option to control SSO HWGRP QoS") Fixes: 20345cbda6d3 ("event/cnxk: support WQE stashing") Fixes: 1b06a817b835 ("event/cnxk: add option to disable NPA") Fixes: e656d40fd12f ("event/cnxk: add option for in-flight buffer count") Fixes: 8a3d58c189fd ("event/cnxk: add option to control timer adapters") Fixes: 8bdbae66b299 ("event/cnxk: add external clock support for timer") Cc: stable@dpdk.org Signed-off-by: Chengwen Feng --- drivers/event/cnxk/cnxk_eventdev.c | 6 ++++++ drivers/event/cnxk/cnxk_eventdev.h | 6 ++++++ drivers/event/cnxk/cnxk_tim_evdev.c | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/drivers/event/cnxk/cnxk_eventdev.c b/drivers/event/cnxk/cnxk_eventdev.c index cb9ba5d353..970681adfc 100644 --- a/drivers/event/cnxk/cnxk_eventdev.c +++ b/drivers/event/cnxk/cnxk_eventdev.c @@ -565,6 +565,9 @@ parse_sso_kvargs_qos_dict(const char *key, const char *value, void *opaque) { RTE_SET_USED(key); + if (value == NULL) + return -EINVAL; + /* Dict format [Qx-TAQ-IAQ][Qz-TAQ-IAQ] use '-' cause ',' isn't allowed. * Everything is expressed in percentages, 0 represents default. */ @@ -578,6 +581,9 @@ parse_sso_kvargs_stash_dict(const char *key, const char *value, void *opaque) { RTE_SET_USED(key); + if (value == NULL) + return -EINVAL; + /* Dict format [Qx||] use '|' cause ',' * isn't allowed. */ diff --git a/drivers/event/cnxk/cnxk_eventdev.h b/drivers/event/cnxk/cnxk_eventdev.h index c7cbd722ab..acd705183c 100644 --- a/drivers/event/cnxk/cnxk_eventdev.h +++ b/drivers/event/cnxk/cnxk_eventdev.h @@ -169,6 +169,9 @@ parse_kvargs_flag(const char *key, const char *value, void *opaque) { RTE_SET_USED(key); + if (value == NULL) + return -EINVAL; + *(uint8_t *)opaque = !!atoi(value); return 0; } @@ -178,6 +181,9 @@ parse_kvargs_value(const char *key, const char *value, void *opaque) { RTE_SET_USED(key); + if (value == NULL) + return -EINVAL; + *(uint32_t *)opaque = (uint32_t)atoi(value); return 0; } diff --git a/drivers/event/cnxk/cnxk_tim_evdev.c b/drivers/event/cnxk/cnxk_tim_evdev.c index 121480df15..e5450fd9bf 100644 --- a/drivers/event/cnxk/cnxk_tim_evdev.c +++ b/drivers/event/cnxk/cnxk_tim_evdev.c @@ -490,6 +490,9 @@ cnxk_tim_parse_kvargs_dict(const char *key, const char *value, void *opaque) { RTE_SET_USED(key); + if (value == NULL) + return -EINVAL; + /* Dict format [ring-chunk_sz-disable_npa-enable_stats] use '-' as ',' * isn't allowed. 0 represents default. */ @@ -528,6 +531,9 @@ cnxk_tim_parse_kvargs_dsv(const char *key, const char *value, void *opaque) { RTE_SET_USED(key); + if (value == NULL) + return -EINVAL; + /* DSV format GPIO-PTP-SYNCE-BTS use '-' as ',' * isn't allowed. 0 represents default. */ -- 2.17.1