From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <stable-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 9C0FCA0542
	for <public@inbox.dpdk.org>; Thu,  4 Aug 2022 11:59:06 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id C105842BCA;
	Thu,  4 Aug 2022 11:59:05 +0200 (CEST)
Received: from mga09.intel.com (mga09.intel.com [134.134.136.24])
 by mails.dpdk.org (Postfix) with ESMTP id 6DFAE4281B;
 Thu,  4 Aug 2022 11:58:59 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
 d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
 t=1659607143; x=1691143143;
 h=from:to:cc:subject:date:message-id:in-reply-to:
 references:mime-version:content-transfer-encoding;
 bh=ScKl0lsNLQbIhWoKlI3AioRWP6VyzDo7pCXhFIqq/fE=;
 b=gpERKG7M8xRT8Rcikxck0PixrT93q7tLH8GKocBRBulmnNIYgnogRWUC
 7WxvBEAM4s3zkypfABMB/x9iuPAt1ajZLxlpDb1uWiu5FmGlYFrunC9jN
 O7AXR0eb6Dvui21e82dIbkNcBCiAMv3AafclWY4Ks3aQwATy6+xICxDr4
 500AHxRyLmm7+KJWlxOQptwMxHRv85kOXiXBucu7j4m5ADjWVxx4lwZci
 TrC8GIBW6O8gkspPZf/9aZlkklzXe2af+bC7jJx9Y7K5XyArFHYR83qR6
 1GgYJhYk+F892mF8cANqf+V4ckNb0w4+SPt+3V7XePdoYEld8YxCUE9Eg w==;
X-IronPort-AV: E=McAfee;i="6400,9594,10428"; a="290669617"
X-IronPort-AV: E=Sophos;i="5.93,215,1654585200"; d="scan'208";a="290669617"
Received: from fmsmga008.fm.intel.com ([10.253.24.58])
 by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 04 Aug 2022 02:58:56 -0700
X-IronPort-AV: E=Sophos;i="5.93,215,1654585200"; d="scan'208";a="662471848"
Received: from unknown (HELO localhost.localdomain) ([10.239.252.104])
 by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 04 Aug 2022 02:58:54 -0700
From: Ke Zhang <ke1x.zhang@intel.com>
To: beilei.xing@intel.com,
	yuying.zhang@intel.com,
	dev@dpdk.org
Cc: Ke Zhang <ke1x.zhang@intel.com>,
	stable@dpdk.org
Subject: [PATCH v5] net/i40e: fix the issue caused by PF and VF release order
Date: Thu,  4 Aug 2022 17:50:03 +0800
Message-Id: <20220804095003.406115-1-ke1x.zhang@intel.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20220715090359.76538-1-ke1x.zhang@intel.com>
References: <20220715090359.76538-1-ke1x.zhang@intel.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-BeenThere: stable@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: patches for DPDK stable branches <stable.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/stable>,
 <mailto:stable-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/stable/>
List-Post: <mailto:stable@dpdk.org>
List-Help: <mailto:stable-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/stable>,
 <mailto:stable-request@dpdk.org?subject=subscribe>
Errors-To: stable-bounces@dpdk.org

A segmentation fault occurs when testpmd exit.

This is due to fetching the device name from PF, PF
is freed firstly and then VF representor is called
later.

This commit fixes the bug by fetching the device
name from VF representor instead of PF.

Fixes: e391a7b7f815 ("net/i40e: fix multi-process shared data")
Cc: stable@dpdk.org

Signed-off-by: Ke Zhang <ke1x.zhang@intel.com>
Acked-by: Yuying Zhang <yuying.zhang@intel.com>
---
v5: Update the commit log
v4: Update the commit log
v3: Change the design and fix code in driver
v2: Change the testpmd code to fix this issue
---
---
 drivers/net/i40e/i40e_vf_representor.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/i40e/i40e_vf_representor.c b/drivers/net/i40e/i40e_vf_representor.c
index 7f8e81858e..bcd445bcdd 100644
--- a/drivers/net/i40e/i40e_vf_representor.c
+++ b/drivers/net/i40e/i40e_vf_representor.c
@@ -29,8 +29,6 @@ i40e_vf_representor_dev_infos_get(struct rte_eth_dev *ethdev,
 	struct rte_eth_dev_info *dev_info)
 {
 	struct i40e_vf_representor *representor = ethdev->data->dev_private;
-	struct rte_eth_dev_data *pf_dev_data =
-		representor->adapter->pf.dev_data;
 
 	/* get dev info for the vdev */
 	dev_info->device = ethdev->device;
@@ -104,7 +102,7 @@ i40e_vf_representor_dev_infos_get(struct rte_eth_dev *ethdev,
 	};
 
 	dev_info->switch_info.name =
-		rte_eth_devices[pf_dev_data->port_id].device->name;
+		rte_eth_devices[ethdev->data->port_id].device->name;
 	dev_info->switch_info.domain_id = representor->switch_domain_id;
 	dev_info->switch_info.port_id = representor->vf_id;
 
-- 
2.25.1