From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 92093AAC2 for ; Fri, 27 Apr 2018 18:42:25 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Apr 2018 09:42:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,335,1520924400"; d="scan'208";a="36681770" Received: from aburakov-mobl.ger.corp.intel.com (HELO [10.252.25.158]) ([10.252.25.158]) by orsmga007.jf.intel.com with ESMTP; 27 Apr 2018 09:42:22 -0700 To: Bruce Richardson Cc: dev@dpdk.org, thomas@monjalon.net References: <36228cdd42eef261936b07c42a3c582f7e715da1.1524650130.git.anatoly.burakov@intel.com> <20180427152116.GE80648@bricha3-MOBL.ger.corp.intel.com> <2942cba5-8446-1d02-b4e7-40f996ec1803@intel.com> <20180427162712.GA102060@bricha3-MOBL.ger.corp.intel.com> From: "Burakov, Anatoly" Message-ID: Date: Fri, 27 Apr 2018 17:42:21 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180427162712.GA102060@bricha3-MOBL.ger.corp.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v3 5/9] mem: fix potential resource leak 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: , X-List-Received-Date: Fri, 27 Apr 2018 16:42:26 -0000 On 27-Apr-18 5:27 PM, Bruce Richardson wrote: > On Fri, Apr 27, 2018 at 04:55:51PM +0100, Burakov, Anatoly wrote: >> On 27-Apr-18 4:21 PM, Bruce Richardson wrote: >>> 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? >> >> Perhaps i should clarify - te->fd and fd are the same fd. >> > Can you clarify that to coverity somehow? > I don't think i can. The fd comes from get_seg_fd(), which finds the tailq entry and either returns existing fd, or opens a new one - and the same tailq entry is later looked up by alloc_seg(). Technically, of course, tailq contents might change inbetween the calls, but really that's not possible as only one thread in any given process is ever running through this code. -- Thanks, Anatoly