From patchwork Wed Nov 1 10:13:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingjin Ye X-Patchwork-Id: 133724 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 77DE04325F; Wed, 1 Nov 2023 11:23:56 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0029940151; Wed, 1 Nov 2023 11:23:55 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mails.dpdk.org (Postfix) with ESMTP id 64269400EF; Wed, 1 Nov 2023 11:23:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698834233; x=1730370233; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dyUuEFXKntQzjorXnJvUu7QjR87+eOXEfhxKP2jexzw=; b=Rn1hLVa16MlTNj7lIRkZkcbwuZdErAhcLcNh9zADp46R1fwvlP46Y7QM FkWGTnoGqd+NmqvkJiUrmDnfJgGRwSpavjcXt1eJwfD+WcdiS/nEsG16Z MxIeLV8Hq88WWNyQWFRg+gy2WLQy3vXF3P7Fv4QDFJSErYNlWBmnpTIiU FkgByqToXzqfcRofFKWXSxZ7yq0JDU72l29ZSUxR5ssUhoHei0Dt+3PUY 7geWMrBiMN6sMgdrip2sbdtpV9lZQkBByH8olghzj3Zxch6mPi3SOosT6 ACJRPSH9VDuShaCV15LEbm7SbzQO38OhBBx9M13kW1qZcA/bbT6lXhSv6 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10880"; a="7096429" X-IronPort-AV: E=Sophos;i="6.03,267,1694761200"; d="scan'208";a="7096429" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 03:23:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.03,267,1694761200"; d="scan'208";a="9002127" Received: from unknown (HELO localhost.localdomain) ([10.239.252.253]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 03:23:49 -0700 From: Mingjin Ye To: dev@dpdk.org Cc: qiming.yang@intel.com, yidingx.zhou@intel.com, Mingjin Ye , stable@dpdk.org, Qi Zhang Subject: [PATCH v3] net/ice: fix crash on closing representor ports Date: Wed, 1 Nov 2023 10:13:47 +0000 Message-Id: <20231101101347.3570418-1-mingjinx.ye@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231030084459.3470038-1-mingjinx.ye@intel.com> References: <20231030084459.3470038-1-mingjinx.ye@intel.com> MIME-Version: 1.0 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 data resource in struct rte_eth_dev is cleared and points to NULL when the DCF port is closed. If the DCF representor port is closed after the DCF port is closed, a segmentation fault occurs because the representor port accesses the data resource released by the DCF port. This patch checks if the resource is present before accessing. Fixes: 5674465a32c8 ("net/ice: add DCF VLAN handling") Fixes: da9cdcd1f372 ("net/ice: fix crash on representor port closing") Cc: stable@dpdk.org Signed-off-by: Mingjin Ye --- v3: New solution. --- drivers/net/ice/ice_dcf_vf_representor.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/ice/ice_dcf_vf_representor.c b/drivers/net/ice/ice_dcf_vf_representor.c index b9fcfc80ad..8c45e28f02 100644 --- a/drivers/net/ice/ice_dcf_vf_representor.c +++ b/drivers/net/ice/ice_dcf_vf_representor.c @@ -111,14 +111,16 @@ ice_dcf_vf_repr_link_update(__rte_unused struct rte_eth_dev *ethdev, static __rte_always_inline struct ice_dcf_hw * ice_dcf_vf_repr_hw(struct ice_dcf_vf_repr *repr) { - struct ice_dcf_adapter *dcf_adapter = - repr->dcf_eth_dev->data->dev_private; + struct rte_eth_dev_data *dcf_data = repr->dcf_eth_dev->data; + struct ice_dcf_adapter *dcf_adapter; - if (!dcf_adapter) { + if (!dcf_data || !dcf_data->dev_private) { PMD_DRV_LOG(ERR, "DCF for VF representor has been released\n"); return NULL; } + dcf_adapter = dcf_data->dev_private; + return &dcf_adapter->real_hw; }