From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 0F35A4F9B; Fri, 23 Nov 2018 18:33:06 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9EE763082DD2; Fri, 23 Nov 2018 17:33:05 +0000 (UTC) Received: from [10.36.112.54] (ovpn-112-54.ams2.redhat.com [10.36.112.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 86FE067E68; Fri, 23 Nov 2018 17:32:58 +0000 (UTC) To: Ilya Maximets , dev@dpdk.org, David Marchand Cc: Tiwei Bie , Zhihong Wang , Thomas Monjalon , Ferruh Yigit , Ian Stokes , Kevin Traynor , Bruce Richardson , stable@dpdk.org References: <20181123143620.10480-1-i.maximets@samsung.com> <20181123153920.12398-1-i.maximets@samsung.com> <20181123153920.12398-2-i.maximets@samsung.com> From: Maxime Coquelin Message-ID: <26d4125a-17e6-0a6e-3e01-f0b66d289609@redhat.com> Date: Fri, 23 Nov 2018 18:32:56 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20181123153920.12398-2-i.maximets@samsung.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 23 Nov 2018 17:33:06 +0000 (UTC) Subject: Re: [dpdk-dev] [PATCH v3 1/2] eal/bsd: fix possible IOPL fd 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, 23 Nov 2018 17:33:07 -0000 On 11/23/18 4:39 PM, Ilya Maximets wrote: > If rte_eal_iopl_init() will be called more than once we'll leak > the file descriptor. > > Fixes: b46fe31862ec ("eal/bsd: fix virtio on FreeBSD") > Cc: stable@dpdk.org > > Signed-off-by: Ilya Maximets > --- > lib/librte_eal/bsdapp/eal/eal.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c > index 508cbc46f..b8152a75c 100644 > --- a/lib/librte_eal/bsdapp/eal/eal.c > +++ b/lib/librte_eal/bsdapp/eal/eal.c > @@ -556,9 +556,11 @@ int rte_eal_has_hugepages(void) > int > rte_eal_iopl_init(void) > { > - static int fd; > + static int fd = -1; > + > + if (fd < 0) > + fd = open("/dev/io", O_RDWR); > > - fd = open("/dev/io", O_RDWR); > if (fd < 0) > return -1; > /* keep fd open for iopl */ > Reviewed-by: Maxime Coquelin