From patchwork Wed Oct 21 11:19:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunjian Wang X-Patchwork-Id: 81695 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 20323A04DF; Wed, 21 Oct 2020 13:19:24 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 010CFAC65; Wed, 21 Oct 2020 13:19:23 +0200 (CEST) Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) by dpdk.org (Postfix) with ESMTP id 97765AC63; Wed, 21 Oct 2020 13:19:20 +0200 (CEST) Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id D45C2D565F1807B674B5; Wed, 21 Oct 2020 19:19:17 +0800 (CST) Received: from localhost (10.174.187.156) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.487.0; Wed, 21 Oct 2020 19:19:07 +0800 From: wangyunjian To: CC: , , , , , Yunjian Wang , Date: Wed, 21 Oct 2020 19:19:03 +0800 Message-ID: <32d8f2e1dca7ba254e6f5667d7198fadf4477349.1603207676.git.wangyunjian@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.174.187.156] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH v5 1/3] eal: fix memory leak when removing event_cb X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Yunjian Wang The event_cb->dev_name is not freed when freeing event_cb, and this causes a memory leak. Fixes: a753e53d517b ("eal: add device event monitor framework") Cc: stable@dpdk.org Signed-off-by: Yunjian Wang Acked-by: Jeff Guo --- lib/librte_eal/common/eal_common_dev.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index 9e4f09d83e..363a2ca95e 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -526,6 +526,7 @@ rte_dev_event_callback_unregister(const char *device_name, */ if (event_cb->active == 0) { TAILQ_REMOVE(&dev_event_cbs, event_cb, next); + free(event_cb->dev_name); free(event_cb); ret++; } else { From patchwork Wed Oct 21 11:19:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunjian Wang X-Patchwork-Id: 81696 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 58F2BA04DF; Wed, 21 Oct 2020 13:19:41 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B2CB6AC62; Wed, 21 Oct 2020 13:19:36 +0200 (CEST) Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) by dpdk.org (Postfix) with ESMTP id 78350AC62; Wed, 21 Oct 2020 13:19:34 +0200 (CEST) Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 9E1A86D94F940B71DDD3; Wed, 21 Oct 2020 19:19:32 +0800 (CST) Received: from localhost (10.174.187.156) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.487.0; Wed, 21 Oct 2020 19:19:24 +0800 From: wangyunjian To: CC: , , , , , Yunjian Wang , Date: Wed, 21 Oct 2020 19:19:23 +0800 Message-ID: <0c755de289f228e67897818639a171cbf1d768ae.1603207676.git.wangyunjian@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.174.187.156] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH v5 2/3] eal: return error code when failure X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Yunjian Wang Fix return value, using -EAGAIN instead of 0 when the callback is busy and using -ENOENT instead of 0 when the callback is not found. Fixes: a753e53d517b ("eal: add device event monitor framework") Cc: stable@dpdk.org Signed-off-by: Yunjian Wang Acked-by: Jeff Guo --- lib/librte_eal/common/eal_common_dev.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index 363a2ca95e..d990bfd20d 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -530,9 +530,15 @@ rte_dev_event_callback_unregister(const char *device_name, free(event_cb); ret++; } else { - continue; + ret = -EAGAIN; + break; } } + + /* this callback is not be registered */ + if (ret == 0) + ret = -ENOENT; + rte_spinlock_unlock(&dev_event_lock); return ret; } From patchwork Wed Oct 21 11:19:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunjian Wang X-Patchwork-Id: 81697 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 95EAAA04DF; Wed, 21 Oct 2020 13:20:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 759EFACAB; Wed, 21 Oct 2020 13:20:02 +0200 (CEST) Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) by dpdk.org (Postfix) with ESMTP id BBAD7AA1E; Wed, 21 Oct 2020 13:19:59 +0200 (CEST) Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id D24A5CB817643C47C8EE; Wed, 21 Oct 2020 19:19:58 +0800 (CST) Received: from localhost (10.174.187.156) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.487.0; Wed, 21 Oct 2020 19:19:50 +0800 From: wangyunjian To: CC: , , , , , Yunjian Wang , Date: Wed, 21 Oct 2020 19:19:49 +0800 Message-ID: <7ec6b12bf0f9fcdb2306dec72390a853abdf2f56.1603207676.git.wangyunjian@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.174.187.156] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH v5 3/3] eal: fix a wrong returned value when callback exists X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Yunjian Wang We should return an error value, when the callback is already exist. Fixes: a753e53d517b ("eal: add device event monitor framework") Cc: stable@dpdk.org Signed-off-by: Yunjian Wang Suggested-by: David Marchand --- lib/librte_eal/common/eal_common_dev.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index d990bfd20d..8a3bd3100a 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -480,7 +480,9 @@ rte_dev_event_callback_register(const char *device_name, RTE_LOG(ERR, EAL, "The callback is already exist, no need " "to register again.\n"); + event_cb = NULL; ret = -EEXIST; + goto error; } rte_spinlock_unlock(&dev_event_lock);