From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id ADF21A052B; Tue, 28 Jul 2020 14:35:39 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 35E3D1BFF3; Tue, 28 Jul 2020 14:35:39 +0200 (CEST) Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35]) by dpdk.org (Postfix) with ESMTP id 5083E1BFF2; Tue, 28 Jul 2020 14:35:38 +0200 (CEST) Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id DDA74F635CDCD506A47F; Tue, 28 Jul 2020 20:35:35 +0800 (CST) Received: from localhost (10.174.185.168) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.487.0; Tue, 28 Jul 2020 20:35:26 +0800 From: wangyunjian To: CC: , , , , Yunjian Wang , Date: Tue, 28 Jul 2020 20:34:46 +0800 Message-ID: <94f09369ca1d8579cf2ee5eece94f684ab0e9909.1595932907.git.wangyunjian@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.185.168] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH] net/hinic: fix return value of null not checked X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Yunjian Wang The function rte_zmalloc() could return NULL, the return value need to be checked. Fixes: f4ca3fd54c4d ("net/hinic: create and destroy flow director filter") Cc: stable@dpdk.org Signed-off-by: Yunjian Wang --- drivers/net/hinic/hinic_pmd_flow.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/net/hinic/hinic_pmd_flow.c b/drivers/net/hinic/hinic_pmd_flow.c index a7bad570b..503a32fff 100644 --- a/drivers/net/hinic/hinic_pmd_flow.c +++ b/drivers/net/hinic/hinic_pmd_flow.c @@ -2977,6 +2977,10 @@ static struct rte_flow *hinic_flow_create(struct rte_eth_dev *dev, if (!ret) { ntuple_filter_ptr = rte_zmalloc("hinic_ntuple_filter", sizeof(struct hinic_ntuple_filter_ele), 0); + if (ntuple_filter_ptr == NULL) { + PMD_DRV_LOG(ERR, "Failed to allocate ntuple_filter_ptr"); + goto out; + } rte_memcpy(&ntuple_filter_ptr->filter_info, &ntuple_filter, sizeof(struct rte_eth_ntuple_filter)); @@ -3003,6 +3007,10 @@ static struct rte_flow *hinic_flow_create(struct rte_eth_dev *dev, ethertype_filter_ptr = rte_zmalloc("hinic_ethertype_filter", sizeof(struct hinic_ethertype_filter_ele), 0); + if (ethertype_filter_ptr == NULL) { + PMD_DRV_LOG(ERR, "Failed to allocate ethertype_filter_ptr"); + goto out; + } rte_memcpy(ðertype_filter_ptr->filter_info, ðertype_filter, sizeof(struct rte_eth_ethertype_filter)); @@ -3036,6 +3044,10 @@ static struct rte_flow *hinic_flow_create(struct rte_eth_dev *dev, if (!ret) { fdir_rule_ptr = rte_zmalloc("hinic_fdir_rule", sizeof(struct hinic_fdir_rule_ele), 0); + if (fdir_rule_ptr == NULL) { + PMD_DRV_LOG(ERR, "Failed to allocate fdir_rule_ptr"); + goto out; + } rte_memcpy(&fdir_rule_ptr->filter_info, &fdir_rule, sizeof(struct hinic_fdir_rule)); TAILQ_INSERT_TAIL(&nic_dev->filter_fdir_rule_list, -- 2.23.0