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 8D9FD41C23 for ; Mon, 6 Feb 2023 16:49:59 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4CBFF42D50; Mon, 6 Feb 2023 16:49:58 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id BCC4B42D3E for ; Mon, 6 Feb 2023 16:49:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675698596; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2x2HWkV6DKNuIk1wRHBAPyfznba2N06q1N7NslAhbkE=; b=F3p2qwOWnX065vY8kMxL+RhExbD3qSqoS6zBivNlTZP80eGNP+cMGA5ZKTwYCgfCo9aY+K RqDAyOKv2AWyms1gMOqvfSqA41/If2pKIKCXn1KHl++Ta9h7wDneyH+vryMt9LYHOeKDws gYQpXxjyi9VuaRW8Va7TINz1vpbTp1U= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-125-YvpEdWV_N3WVZuqKQmkcKA-1; Mon, 06 Feb 2023 10:49:51 -0500 X-MC-Unique: YvpEdWV_N3WVZuqKQmkcKA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 21D25858F09; Mon, 6 Feb 2023 15:49:50 +0000 (UTC) Received: from dmarchan.redhat.com (ovpn-195-46.brq.redhat.com [10.40.195.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id 811D6140EBF6; Mon, 6 Feb 2023 15:49:48 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: stable@dpdk.org, Aman Singh , Yuying Zhang , Ferruh Yigit , Stephen Hemminger , Thomas Monjalon Subject: [PATCH] app/testpmd: fix crash on cleanup Date: Mon, 6 Feb 2023 16:49:46 +0100 Message-Id: <20230206154946.750829-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org If allocating the ports[] array fails, a crash will occur when shutting down testpmd since ethdev emits RTE_ETH_EVENT_DESTROY events. Move init_port() before registering ethdev event handler. Fixes: 85c6571c9103 ("app/testpmd: reset port status on close notification") Cc: stable@dpdk.org Signed-off-by: David Marchand --- app/test-pmd/testpmd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index e366f81a0f..de3017fd62 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -4385,6 +4385,9 @@ main(int argc, char** argv) rte_exit(EXIT_FAILURE, "Cannot init EAL: %s\n", rte_strerror(rte_errno)); + /* allocate port structures, and init them */ + init_port(); + ret = register_eth_event_callback(); if (ret != 0) rte_exit(EXIT_FAILURE, "Cannot register for ethdev events"); @@ -4403,9 +4406,6 @@ main(int argc, char** argv) if (nb_ports == 0) TESTPMD_LOG(WARNING, "No probed ethernet devices\n"); - /* allocate port structures, and init them */ - init_port(); - set_def_fwd_config(); if (nb_lcores == 0) rte_exit(EXIT_FAILURE, "No cores defined for forwarding\n" -- 2.39.1