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 A6DE5A0C4D for ; Tue, 7 Sep 2021 04:01:53 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9464441104; Tue, 7 Sep 2021 04:01:53 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 74D3940DF8; Tue, 7 Sep 2021 04:01:50 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10099"; a="207190671" X-IronPort-AV: E=Sophos;i="5.85,273,1624345200"; d="scan'208";a="207190671" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2021 19:01:39 -0700 X-IronPort-AV: E=Sophos;i="5.85,273,1624345200"; d="scan'208";a="546490777" Received: from unknown (HELO localhost.localdomain) ([10.240.183.93]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2021 19:01:37 -0700 From: dapengx.yu@intel.com To: Qiming Yang , Qi Zhang Cc: dev@dpdk.org, haiyue.wang@intel.com, Dapeng Yu , stable@dpdk.org Date: Tue, 7 Sep 2021 10:00:33 +0800 Message-Id: <20210907020033.2113437-1-dapengx.yu@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210903054140.1530911-1-dapengx.yu@intel.com> References: <20210903054140.1530911-1-dapengx.yu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH v3] net/ice: fix representor port segmentation fault X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" From: Dapeng Yu If DCF representor port is closed after DCF port is closed, there will be segmentation fault because representor accesses the released resource of DCF port. This patch checks if the resource is present before accessing. Fixes: 5674465a32c8 ("net/ice: add DCF VLAN handling") Cc: stable@dpdk.org Signed-off-by: Dapeng Yu --- V2: * Remove (void) to make code clean. V3: * Only check resource accessibility but not release it. --- drivers/net/ice/ice_dcf_vf_representor.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/ice/ice_dcf_vf_representor.c b/drivers/net/ice/ice_dcf_vf_representor.c index 970461f3e9..b547c42f91 100644 --- a/drivers/net/ice/ice_dcf_vf_representor.c +++ b/drivers/net/ice/ice_dcf_vf_representor.c @@ -114,6 +114,11 @@ ice_dcf_vf_repr_hw(struct ice_dcf_vf_repr *repr) struct ice_dcf_adapter *dcf_adapter = repr->dcf_eth_dev->data->dev_private; + if (!dcf_adapter) { + PMD_DRV_LOG(ERR, "DCF for VF representor has been released\n"); + return NULL; + } + return &dcf_adapter->real_hw; } @@ -124,6 +129,9 @@ ice_dcf_vf_repr_dev_info_get(struct rte_eth_dev *dev, struct ice_dcf_vf_repr *repr = dev->data->dev_private; struct ice_dcf_hw *dcf_hw = ice_dcf_vf_repr_hw(repr); + if (!dcf_hw) + return -EIO; + dev_info->device = dev->device; dev_info->max_mac_addrs = 1; dev_info->max_rx_queues = dcf_hw->vsi_res->num_queue_pairs; -- 2.27.0