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 86C90A053D for ; Fri, 17 Jul 2020 13:44:51 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 61EEC1C07D; Fri, 17 Jul 2020 13:44:51 +0200 (CEST) Received: from huawei.com (szxga01-in.huawei.com [45.249.212.187]) by dpdk.org (Postfix) with ESMTP id 554181C07D; Fri, 17 Jul 2020 13:44:50 +0200 (CEST) Received: from DGGEMM403-HUB.china.huawei.com (unknown [172.30.72.57]) by Forcepoint Email with ESMTP id 1F572252559651989618; Fri, 17 Jul 2020 19:44:47 +0800 (CST) Received: from DGGEMM533-MBX.china.huawei.com ([169.254.5.165]) by DGGEMM403-HUB.china.huawei.com ([10.3.20.211]) with mapi id 14.03.0487.000; Fri, 17 Jul 2020 19:44:41 +0800 From: wangyunjian To: "dev@dpdk.org" , "david.marchand@redhat.com" , "ferruh.yigit@intel.com" CC: "Lilijun (Jerry)" , xudingke , "stable@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] eal: fix memory leak in uevent parse and process Thread-Index: AQHWMPBAGqU8TrE+pE2WVWJhjq7Xi6kL/OnA Date: Fri, 17 Jul 2020 11:44:41 +0000 Message-ID: <34EFBCA9F01B0748BEB6B629CE643AE60D0D6689@DGGEMM533-MBX.china.huawei.com> References: <1590231141-30684-1-git-send-email-wangyunjian@huawei.com> In-Reply-To: <1590231141-30684-1-git-send-email-wangyunjian@huawei.com> Accept-Language: en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.174.185.168] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-CFilter-Loop: Reflected Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH] eal: fix memory leak in uevent parse and process X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 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 Sender: "stable" Is there any ideas on this bug? Ping for review, please. Yunjian > -----Original Message----- > From: wangyunjian > Sent: Saturday, May 23, 2020 6:52 PM > To: dev@dpdk.org > Cc: Lilijun (Jerry) ; xudingke > ; wangyunjian ; > stable@dpdk.org > Subject: [dpdk-dev] [PATCH] eal: fix memory leak in uevent parse and proc= ess >=20 > From: Yunjian Wang >=20 > When the memory for uevent.devname is allocated in dev_uev_parse(). It is= not > freed when parse the subsystem layer fails in dev_uev_parse(). > And Before return, it is also not freed in dev_uev_handler(). These cause= a > memory leak. >=20 > Fixes: 0d0f478d0483 ("eal/linux: add uevent parse and process") > Cc: stable@dpdk.org >=20 > Signed-off-by: Yunjian Wang > --- > lib/librte_eal/linux/eal_dev.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) >=20 > diff --git a/lib/librte_eal/linux/eal_dev.c b/lib/librte_eal/linux/eal_de= v.c index > 83c9cd660..3a2bf8514 100644 > --- a/lib/librte_eal/linux/eal_dev.c > +++ b/lib/librte_eal/linux/eal_dev.c > @@ -189,7 +189,7 @@ dev_uev_parse(const char *buf, struct rte_dev_event > *event, int length) > else if (!strncmp(subsystem, "vfio", 4)) > event->subsystem =3D EAL_DEV_EVENT_SUBSYSTEM_VFIO; > else > - return -1; > + goto out; >=20 > /* parse the action type */ > if (!strncmp(action, "add", 3)) > @@ -197,8 +197,12 @@ dev_uev_parse(const char *buf, struct rte_dev_event > *event, int length) > else if (!strncmp(action, "remove", 6)) > event->type =3D RTE_DEV_EVENT_REMOVE; > else > - return -1; > + goto out; > return 0; > +out: > + if (event->devname) > + free(event->devname); > + return -1; > } >=20 > static void > @@ -277,12 +281,14 @@ dev_uev_handler(__rte_unused void *param) > rte_spinlock_unlock(&failure_handle_lock); > } > rte_dev_event_callback_process(uevent.devname, uevent.type); > + free(uevent.devname); > } >=20 > return; >=20 > failure_handle_err: > rte_spinlock_unlock(&failure_handle_lock); > + free(uevent.devname); > } >=20 > int > -- > 2.23.0 >=20