From patchwork Thu Jul 18 19:37:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Long Li X-Patchwork-Id: 142520 X-Patchwork-Delegate: david.marchand@redhat.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 107A045648; Thu, 18 Jul 2024 21:37:36 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E5FF540EDB; Thu, 18 Jul 2024 21:37:35 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 5139840E18; Thu, 18 Jul 2024 21:37:34 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1202) id A079120B7165; Thu, 18 Jul 2024 12:37:33 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A079120B7165 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxonhyperv.com; s=default; t=1721331453; bh=WWXUReL9GZqEVTylYXIp64ihh+7XSIGIwkV5RwN7H3g=; h=From:To:Cc:Subject:Date:From; b=KnU5Sc6x/DursL4PxhNdvEQTNCVK0u8vV82A0SDAsnZmUQNfotCj1X618bVmvwXbh iP+/5vP6qLhXi8F3Hj1BqtmotniE4C+pQc11JAUZTeAOJzxEfHa4b21mL5TjSX2Emw AUCyzouUTtxVJw3u5tklTTfQK3AnKRzp3XtvFFEk= From: longli@linuxonhyperv.com To: Tyler Retzlaff Cc: dev@dpdk.org, Malcolm Bumgardner , stable@dpdk.org, Long Li Subject: [PATCH] eal: fix device unregister for event registered with device_name NULL Date: Thu, 18 Jul 2024 12:37:28 -0700 Message-Id: <1721331448-9225-1-git-send-email-longli@linuxonhyperv.com> X-Mailer: git-send-email 1.8.3.1 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 From: Malcolm Bumgardner In the device event unregister code, it unconditionally remove all callbacks which are registered with device_name set to NULL. This results in many callbacks uncorrectly removed. Fix this by only removing callbacks with matching cb_fn and cb_arg. Signed-off-by: Malcolm Bumgardner Fixes: a753e53d517b ("eal: add device event monitor framework") Cc: stable@dpdk.org Signed-off-by: Long Li Reviewed-by: Stephen Hemminger Reviewed-by: Stephen Hemminger --- lib/eal/common/eal_common_dev.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/eal/common/eal_common_dev.c b/lib/eal/common/eal_common_dev.c index a99252b02f..70aa04dcd9 100644 --- a/lib/eal/common/eal_common_dev.c +++ b/lib/eal/common/eal_common_dev.c @@ -550,16 +550,17 @@ rte_dev_event_callback_unregister(const char *device_name, next = TAILQ_NEXT(event_cb, next); if (device_name != NULL && event_cb->dev_name != NULL) { - if (!strcmp(event_cb->dev_name, device_name)) { - if (event_cb->cb_fn != cb_fn || - (cb_arg != (void *)-1 && - event_cb->cb_arg != cb_arg)) - continue; - } + if (strcmp(event_cb->dev_name, device_name)) + continue; } else if (device_name != NULL) { continue; } + /* Remove only matching callback with arg */ + if (event_cb->cb_fn != cb_fn || + (cb_arg != (void *)-1 && event_cb->cb_arg != cb_arg)) + continue; + /* * if this callback is not executing right now, * then remove it.