From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id ECD74A0519; Fri, 3 Jul 2020 08:04:50 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CC62F1D9C7; Fri, 3 Jul 2020 08:04:50 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 4701C1D929; Fri, 3 Jul 2020 08:04:49 +0200 (CEST) IronPort-SDR: RkGKWJRfc0FppWPfYSlandUODj3RIHq387rdNYf7+Xw/TriSZCrszk3LagQQuyYSy4y+Lc1K3J +Tjt57F3CN3Q== X-IronPort-AV: E=McAfee;i="6000,8403,9670"; a="126710661" X-IronPort-AV: E=Sophos;i="5.75,307,1589266800"; d="scan'208";a="126710661" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2020 23:04:48 -0700 IronPort-SDR: RWyen9H6nTuOSJDjx/HRE5RpHqEJ+55u0OQNiU6HKNCgXNexs/4ShuBu+nzaqRm0qY0s8NF6H6 Xw3DsZ7tLMRA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,307,1589266800"; d="scan'208";a="278335006" Received: from jguo15x-mobl.ccr.corp.intel.com (HELO [10.67.68.176]) ([10.67.68.176]) by orsmga003.jf.intel.com with ESMTP; 02 Jul 2020 23:04:46 -0700 To: wangyunjian , dev@dpdk.org Cc: jerry.lilijun@huawei.com, xudingke@huawei.com, stable@dpdk.org References: <1593690428-12708-1-git-send-email-wangyunjian@huawei.com> From: Jeff Guo Message-ID: <4c7becd3-4d64-0e20-ea16-d1bd7b4bd6a2@intel.com> Date: Fri, 3 Jul 2020 14:04:46 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <1593690428-12708-1-git-send-email-wangyunjian@huawei.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Subject: Re: [dpdk-dev] [PATCH v3 1/2] 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" hi, yunjian On 7/2/2020 7:47 PM, wangyunjian wrote: > 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 > --- > 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 9e4f09d..4cfdb80 100644 > --- a/lib/librte_eal/common/eal_common_dev.c > +++ b/lib/librte_eal/common/eal_common_dev.c > @@ -526,6 +526,8 @@ static int cmp_dev_name(const struct rte_device *dev, const void *_name) > */ > if (event_cb->active == 0) { > TAILQ_REMOVE(&dev_event_cbs, event_cb, next); > + if (event_cb->dev_name) > + free(event_cb->dev_name); > free(event_cb); > ret++; > } else { After you check, don't you think the memory leak would not occur in rte_dev_event_callback_register when free event_cb? And if you have find other same problem, suggest to fix it wholly by this good chance. Thanks. int rte_dev_event_callback_register(const char *device_name,                 rte_dev_event_cb_fn cb_fn,                 void *cb_arg) { error:     free(event_cb);     rte_spinlock_unlock(&dev_event_lock);     return ret; }