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 A0489A0032; Tue, 21 Jun 2022 11:32:03 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 958D74280C; Tue, 21 Jun 2022 11:32:03 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id C4F4740151; Tue, 21 Jun 2022 11:32:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655803921; x=1687339921; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NA6jU0L2p+U+48AVOying7up8VshkzlWdCQgxt/X/wc=; b=Vaqou1lYHrKVrFf/2veMeu1xa8ni9ZyPuTTLrMJXy5AC7GHY1wtkJdgh 6tB5xZOc4/aQw61PFRNEdfGuENTAu/aUsw7UaINHYT4Ixn4y85/qOFqph /cMrcL0eML/arztjfG3CN7D4zHNeRkgztFTInkYBzBBZcbSh8jknVBJ/P xlWKUzS5AErugMMY8ogM6VmtuYGTBxzql6uLIEdtvAkc78eeHAbMuJWRM Pjc7LrKDVUVpCtpg72dcCJjVQnP/EpYEktG2He99M1rz4ZcI7Ts1HrLIV RKYNs0v3Ak7wq/0P8u2O7gGrbnnCHcC95H7+7ChwUhw1bO1xrs3idKBHn A==; X-IronPort-AV: E=McAfee;i="6400,9594,10384"; a="281133651" X-IronPort-AV: E=Sophos;i="5.92,209,1650956400"; d="scan'208";a="281133651" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jun 2022 02:31:59 -0700 X-IronPort-AV: E=Sophos;i="5.92,209,1650956400"; d="scan'208";a="914060172" Received: from unknown (HELO localhost.localdomain) ([10.239.252.104]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jun 2022 02:31:57 -0700 From: Ke Zhang To: xiaoyun.li@intel.com, aman.deep.singh@intel.com, yuying.zhang@intel.com, dev@dpdk.org Cc: Ke Zhang , stable@dpdk.org Subject: [PATCH v2] app/testpmd: fix quit testpmd with vfs and pf Date: Tue, 21 Jun 2022 17:24:53 +0800 Message-Id: <20220621092453.185583-1-ke1x.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220322071833.199619-1-ke1x.zhang@intel.com> References: <20220322071833.199619-1-ke1x.zhang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 When testpmd startups with pf and vfs,this error occurs when quitting, results in pf is released before vfs ,so the vf would access an freed heap memory. The solution is two steps: 1. Fetch the valid port value from RTE_ETH_FOREACH_DEV. 2. free the port in reverse order. Fixes: 08fd782b8454 ("app/testpmd: fix quit to stop all ports before close") Cc: stable@dpdk.org Signed-off-by: Ke Zhang --- app/test-pmd/testpmd.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 04c39adc21..c01ecf7279 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -3492,16 +3492,32 @@ pmd_test_exit(void) } #endif if (ports != NULL) { + portid_t ethports[RTE_MAX_ETHPORTS]; + int count = 0; + int index = 0; no_link_check = 1; + + /* Fetch the valid port id from port list*/ RTE_ETH_FOREACH_DEV(pt_id) { - printf("\nStopping port %d...\n", pt_id); + ethports[count] = pt_id; + count++; + } + + /* + * Free the port from Reverse order, as general, + * PF port < VF port, VF should be free before PF + * be free. + */ + for (index = count - 1 ; index >= 0 ; index--) { + printf("\nStopping port %d...\n", ethports[index]); fflush(stdout); - stop_port(pt_id); + stop_port(ethports[index]); } - RTE_ETH_FOREACH_DEV(pt_id) { - printf("\nShutting down port %d...\n", pt_id); + + for (index = count - 1 ; index >= 0 ; index--) { + printf("\nShutting down port %d...\n", ethports[index]); fflush(stdout); - close_port(pt_id); + close_port(ethports[index]); } } -- 2.25.1