From patchwork Mon Feb 6 15:49:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 123157 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 23B2A41C23; Mon, 6 Feb 2023 16:49:56 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 08C1642B7E; Mon, 6 Feb 2023 16:49:56 +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 C1385427E9 for ; Mon, 6 Feb 2023 16:49:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675698594; 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=TMLVMeJtQkpwdKlIjUcOuQg0aEMxgZYDPMvCOp5UU+fIRJp5d+DFhADNXWPJO78hNjsR95 GExgFSlk3gu7z1xXfVea/KGhGP6Wpj0nmt/VgyWlV4FEONV5pCOAe7BmUUVQym1k1UrnBu O2h1PyC1slbnLihaP74vKh//wGHodOY= 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 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 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 Acked-by: Aman Singh --- 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"