From patchwork Wed May 30 06:31:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "De Lara Guarch, Pablo" X-Patchwork-Id: 40516 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3884F37AF; Wed, 30 May 2018 16:34:02 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 86C241B0B for ; Wed, 30 May 2018 16:34:00 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 May 2018 07:33:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,460,1520924400"; d="scan'208";a="53446917" Received: from silpixa00399500.ir.intel.com (HELO silpixa00399500.ger.corp.intel.com) ([10.237.223.204]) by FMSMGA003.fm.intel.com with ESMTP; 30 May 2018 07:33:58 -0700 From: Pablo de Lara To: wenzhuo.lu@intel.com, konstantin.ananyev@intel.com Cc: dev@dpdk.org, Pablo de Lara Date: Wed, 30 May 2018 07:31:56 +0100 Message-Id: <20180530063156.17902-1-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 2.13.6 Subject: [dpdk-dev] [PATCH] net/ixgbe: fix crash on detach 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" When detaching a port bound to ixgbe PMD, if the port does not have any VFs, *vfinfo is not set and there is a NULL dereference attempt, when calling rte_eth_switch_domain_free(), which expects VFs to be used, causing a segmentation fault. Steps to reproduce: ./testpmd -- -i testpmd> port stop all testpmd> port close all testpmd> port detach 0 Fixes: cf80ba6e2038 ("net/ixgbe: add support for representor ports") Reported-by: Anatoly Burakov Signed-off-by: Pablo de Lara Tested-by: Anatoly Burakov Acked-by: Remy Horton --- drivers/net/ixgbe/ixgbe_pf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c index 4d199c802..c381acf44 100644 --- a/drivers/net/ixgbe/ixgbe_pf.c +++ b/drivers/net/ixgbe/ixgbe_pf.c @@ -135,14 +135,14 @@ void ixgbe_pf_host_uninit(struct rte_eth_dev *eth_dev) RTE_ETH_DEV_SRIOV(eth_dev).def_vmdq_idx = 0; RTE_ETH_DEV_SRIOV(eth_dev).def_pool_q_idx = 0; - ret = rte_eth_switch_domain_free((*vfinfo)->switch_domain_id); - if (ret) - PMD_INIT_LOG(WARNING, "failed to free switch domain: %d", ret); - vf_num = dev_num_vf(eth_dev); if (vf_num == 0) return; + ret = rte_eth_switch_domain_free((*vfinfo)->switch_domain_id); + if (ret) + PMD_INIT_LOG(WARNING, "failed to free switch domain: %d", ret); + rte_free(*vfinfo); *vfinfo = NULL; }