From patchwork Mon Oct 19 12:26:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Walsh X-Patchwork-Id: 81360 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 48289A04DC; Mon, 19 Oct 2020 14:26:53 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 901C3C962; Mon, 19 Oct 2020 14:26:38 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id DA144C94A for ; Mon, 19 Oct 2020 14:26:33 +0200 (CEST) IronPort-SDR: jr7QO5dvv4iIgjGQiQfxg/E+nVJwrUHpnM70x+ckcg25UEYRarK+0LCvdq7bcKSYmudFBbY8Fz FZzJITAmFuJQ== X-IronPort-AV: E=McAfee;i="6000,8403,9778"; a="153955282" X-IronPort-AV: E=Sophos;i="5.77,394,1596524400"; d="scan'208";a="153955282" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2020 05:26:28 -0700 IronPort-SDR: IIYvThQOJzNu5GQEz+RDUuZGCPlqgD+BpW/5R0N8BD6+IyTSeeW8LuLkJx1Xo1B81u9wGQmpoW Mdh8Pv/5SLNQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,394,1596524400"; d="scan'208";a="352963484" Received: from silpixa00400466.ir.intel.com ([10.237.213.98]) by fmsmga002.fm.intel.com with ESMTP; 19 Oct 2020 05:26:27 -0700 From: Conor Walsh To: jia.guo@intel.com, haiyue.wang@intel.com, ferruh.yigit@intel.com, mohammad.abdul.awal@intel.com, declan.doherty@intel.com Cc: dev@dpdk.org, Conor Walsh Date: Mon, 19 Oct 2020 12:26:19 +0000 Message-Id: <20201019122620.749625-2-conor.walsh@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201019122620.749625-1-conor.walsh@intel.com> References: <20201019122620.749625-1-conor.walsh@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 1/2] net/ixgbe: fix unchecked return value 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" The return value of rte_eth_switch_domain_alloc() was not being checked within ixgbe_pf_host_init() which caused a coverity issue. If the call fails a warning is logged using PMD_INIT_LOG() and *vfinfo is free'd. ixgbe_pf_host_init() now has a return value which is checked in eth_ixgbe_dev_init() Coverity issue: 362795 Fixes: cf80ba6e2038 ("net/ixgbe: add support for representor ports") Signed-off-by: Conor Walsh --- drivers/net/ixgbe/ixgbe_ethdev.c | 6 ++++-- drivers/net/ixgbe/ixgbe_ethdev.h | 2 +- drivers/net/ixgbe/ixgbe_pf.c | 16 +++++++++++++--- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 14a254ab74..49ff523ea8 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -1077,7 +1077,7 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused) IXGBE_DEV_PRIVATE_TO_BW_CONF(eth_dev->data->dev_private); uint32_t ctrl_ext; uint16_t csum; - int diag, i; + int diag, i, ret; PMD_INIT_FUNC_TRACE(); @@ -1256,7 +1256,9 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused) memset(hwstrip, 0, sizeof(*hwstrip)); /* initialize PF if max_vfs not zero */ - ixgbe_pf_host_init(eth_dev); + ret = ixgbe_pf_host_init(eth_dev); + if (ret) + return ret; ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT); /* let hardware know driver is loaded */ diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h index 9bdef87fbd..89fa472356 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.h +++ b/drivers/net/ixgbe/ixgbe_ethdev.h @@ -717,7 +717,7 @@ void ixgbe_vlan_hw_filter_disable(struct rte_eth_dev *dev); void ixgbe_vlan_hw_strip_config(struct rte_eth_dev *dev); -void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev); +int ixgbe_pf_host_init(struct rte_eth_dev *eth_dev); void ixgbe_pf_host_uninit(struct rte_eth_dev *eth_dev); diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c index ed5f96b1a4..4e25b1e72e 100644 --- a/drivers/net/ixgbe/ixgbe_pf.c +++ b/drivers/net/ixgbe/ixgbe_pf.c @@ -66,7 +66,7 @@ ixgbe_mb_intr_setup(struct rte_eth_dev *dev) return 0; } -void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev) +int ixgbe_pf_host_init(struct rte_eth_dev *eth_dev) { struct ixgbe_vf_info **vfinfo = IXGBE_DEV_PRIVATE_TO_P_VFDATA(eth_dev->data->dev_private); @@ -78,19 +78,27 @@ void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev) IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); uint16_t vf_num; uint8_t nb_queue; + int ret = 0; PMD_INIT_FUNC_TRACE(); RTE_ETH_DEV_SRIOV(eth_dev).active = 0; vf_num = dev_num_vf(eth_dev); if (vf_num == 0) - return; + return ret; *vfinfo = rte_zmalloc("vf_info", sizeof(struct ixgbe_vf_info) * vf_num, 0); if (*vfinfo == NULL) rte_panic("Cannot allocate memory for private VF data\n"); - rte_eth_switch_domain_alloc(&(*vfinfo)->switch_domain_id); + ret = rte_eth_switch_domain_alloc(&(*vfinfo)->switch_domain_id); + if (ret) { + PMD_INIT_LOG(ERR, + "failed to allocate switch domain for device %d", ret); + rte_free(*vfinfo); + *vfinfo = NULL; + return ret; + } memset(mirror_info, 0, sizeof(struct ixgbe_mirror_info)); memset(uta_info, 0, sizeof(struct ixgbe_uta_info)); @@ -118,6 +126,8 @@ void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev) /* set mb interrupt mask */ ixgbe_mb_intr_setup(eth_dev); + + return ret; } void ixgbe_pf_host_uninit(struct rte_eth_dev *eth_dev)