From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <stable-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 2DF7EA04AB
	for <public@inbox.dpdk.org>; Tue, 12 Nov 2019 09:47:53 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id EB96091;
	Tue, 12 Nov 2019 09:47:52 +0100 (CET)
Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])
 by dpdk.org (Postfix) with ESMTP id 0CF6D91
 for <stable@dpdk.org>; Tue, 12 Nov 2019 09:47:50 +0100 (CET)
Received: from Internal Mail-Server by MTLPINE1 (envelope-from
 matan@mellanox.com)
 with ESMTPS (AES256-SHA encrypted); 12 Nov 2019 10:47:47 +0200
Received: from pegasus07.mtr.labs.mlnx (pegasus07.mtr.labs.mlnx
 [10.210.16.112])
 by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id xAC8ll0h025250;
 Tue, 12 Nov 2019 10:47:47 +0200
From: Matan Azrad <matan@mellanox.com>
To: dev@dpdk.org
Cc: Gaetan Rivet <gaetan.rivet@6wind.com>,
 Bernard Iremonger <bernard.iremonger@intel.com>, thomas@monjalon.net,
 stable@dpdk.org
Date: Tue, 12 Nov 2019 08:47:39 +0000
Message-Id: <1573548459-6931-2-git-send-email-matan@mellanox.com>
X-Mailer: git-send-email 1.8.3.1
In-Reply-To: <1573548459-6931-1-git-send-email-matan@mellanox.com>
References: <1573548459-6931-1-git-send-email-matan@mellanox.com>
Subject: [dpdk-stable] [PATCH 2/2] app/testpmd: fix invalid port detaching
X-BeenThere: stable@dpdk.org
X-Mailman-Version: 2.1.15
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
Sender: "stable" <stable-bounces@dpdk.org>

The port was not validated before detaching.

Ignore port detach operation when the port is not valid.

Fixes: f8e5baa2662d ("app/testpmd: check not detaching device twice")
Cc: thomas@monjalon.net
Cc: stable@dpdk.org

Signed-off-by: Matan Azrad <matan@mellanox.com>
---
 app/test-pmd/testpmd.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 4444346..370eefe 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -2545,6 +2545,9 @@ struct extmem_param {
 
 	printf("Removing a device...\n");
 
+	if (port_id_is_invalid(port_id, ENABLED_WARN))
+		return;
+
 	dev = rte_eth_devices[port_id].device;
 	if (dev == NULL) {
 		printf("Device already removed\n");
-- 
1.8.3.1