From patchwork Tue Sep 7 02:00:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yu, DapengX" X-Patchwork-Id: 98101 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 mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1F10DA0C41; 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 A2208410EB; Tue, 7 Sep 2021 04:01:52 +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 Subject: [dpdk-dev] [PATCH v3] net/ice: fix representor port segmentation fault 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 Sender: "dev" 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 Acked-by: Haiyue Wang --- 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;