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 7E09EA00BE; Mon, 27 Apr 2020 13:12:25 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BD3641C23E; Mon, 27 Apr 2020 13:12:23 +0200 (CEST) Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by dpdk.org (Postfix) with ESMTP id 58BFF37B1; Mon, 27 Apr 2020 13:12:22 +0200 (CEST) X-Originating-IP: 86.246.31.132 Received: from u256.net (lfbn-idf2-1-566-132.w86-246.abo.wanadoo.fr [86.246.31.132]) (Authenticated sender: grive@u256.net) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 8EE3C60004; Mon, 27 Apr 2020 11:12:21 +0000 (UTC) Date: Mon, 27 Apr 2020 13:12:10 +0200 From: =?utf-8?Q?Ga=C3=ABtan?= Rivet To: wangyunjian Cc: dev@dpdk.org, jerry.lilijun@huawei.com, xudingke@huawei.com, stable@dpdk.org Message-ID: <20200427111210.7pm3rkifd2zcrxjo@u256.net> References: <1587984259-18296-1-git-send-email-wangyunjian@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1587984259-18296-1-git-send-email-wangyunjian@huawei.com> Subject: Re: [dpdk-dev] [PATCH] net/failsafe: fix 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 27/04/20 18:44 +0800, wangyunjian wrote: > From: Yunjian Wang > > Zero is a valid fd. The fd won't be closed thus leading fd leak, > when it is zero. > > Fixes: f234e5bd996d ("net/failsafe: register slaves Rx interrupts") > Fixes: 9e0360aebf23 ("net/failsafe: register as Rx interrupt mode") > Cc: stable@dpdk.org > Hello Yunjian, Nothing prevents a DPDK app from closing 0 and getting it from another call, good catch. > Signed-off-by: Yunjian Wang Acked-by: Gaetan Rivet > --- > drivers/net/failsafe/failsafe_intr.c | 2 +- > drivers/net/failsafe/failsafe_ops.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/failsafe/failsafe_intr.c b/drivers/net/failsafe/failsafe_intr.c > index d8728fe7e..602c04033 100644 > --- a/drivers/net/failsafe/failsafe_intr.c > +++ b/drivers/net/failsafe/failsafe_intr.c > @@ -393,7 +393,7 @@ fs_rx_event_proxy_uninstall(struct fs_priv *priv) > free(priv->rxp.evec); > priv->rxp.evec = NULL; > } > - if (priv->rxp.efd > 0) { > + if (priv->rxp.efd >= 0) { > close(priv->rxp.efd); > priv->rxp.efd = -1; > } > diff --git a/drivers/net/failsafe/failsafe_ops.c b/drivers/net/failsafe/failsafe_ops.c > index 50f2aca4e..e1d08e46c 100644 > --- a/drivers/net/failsafe/failsafe_ops.c > +++ b/drivers/net/failsafe/failsafe_ops.c > @@ -380,7 +380,7 @@ fs_rx_queue_release(void *queue) > rxq = queue; > dev = &rte_eth_devices[rxq->priv->data->port_id]; > fs_lock(dev, 0); > - if (rxq->event_fd > 0) > + if (rxq->event_fd >= 0) > close(rxq->event_fd); > FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { > if (ETH(sdev)->data->rx_queues != NULL && > -- > 2.19.1 > > -- Gaëtan