From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bruce Richardson Subject: Re: [PATCH v3 5/9] mem: fix potential resource leak Date: Fri, 27 Apr 2018 16:21:17 +0100 Message-ID: <20180427152116.GE80648@bricha3-MOBL.ger.corp.intel.com> References: <36228cdd42eef261936b07c42a3c582f7e715da1.1524650130.git.anatoly.burakov@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: dev@dpdk.org, thomas@monjalon.net To: Anatoly Burakov Return-path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 437005F3B for ; Fri, 27 Apr 2018 17:21:21 +0200 (CEST) Content-Disposition: inline In-Reply-To: <36228cdd42eef261936b07c42a3c582f7e715da1.1524650130.git.anatoly.burakov@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Wed, Apr 25, 2018 at 10:56:43AM +0100, Anatoly Burakov wrote: > Normally, tailq entry should have a valid fd by the time we attempt > to map the segment. However, in case it doesn't, we're leaking fd, > so fix it. > > Coverity issue: 272570 > > Fixes: 2a04139f66b4 ("eal: add single file segments option") > Cc: anatoly.burakov@intel.com > > Signed-off-by: Anatoly Burakov > --- > lib/librte_eal/linuxapp/eal/eal_memalloc.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/lib/librte_eal/linuxapp/eal/eal_memalloc.c b/lib/librte_eal/linuxapp/eal/eal_memalloc.c > index fab5a98..b02e3a5 100644 > --- a/lib/librte_eal/linuxapp/eal/eal_memalloc.c > +++ b/lib/librte_eal/linuxapp/eal/eal_memalloc.c > @@ -524,6 +524,8 @@ alloc_seg(struct rte_memseg *ms, void *addr, int socket_id, > if (te != NULL && te->fd >= 0) { > close(te->fd); > te->fd = -1; Is "fd" still not being leaked here, since we won't hit the else case and then jump to the end of the function where it goes out of scope? > + } else { > + close(fd); > } > /* ignore errors, can't make it any worse */ > unlink(path); > -- > 2.7.4