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 00BDEA09E0; Fri, 11 Dec 2020 17:50:46 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 93A08C952; Fri, 11 Dec 2020 17:50:44 +0100 (CET) Received: from m12-13.163.com (m12-13.163.com [220.181.12.13]) by dpdk.org (Postfix) with ESMTP id 02C67C950 for ; Fri, 11 Dec 2020 17:50:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=iukThcZG2Ybe4Q1U9Y uz7stM7dQRyZOJjPth3nVg7qo=; b=jcrxTxk0j47NGwJFif8Zp/TolhIuPAz9RO yDKPxf2stU9BFBL10A5yWlbQ57P/2/Xb+03L+I7t9y5GeNf8UUeJRRJT2wdCRecQ UOeI09J5xvNIsuBDnbVQkgtdd78FAC1Ajbb7ebWQ6SXyqHU4i2EIOWHItLEeSZEV hUYJ1Iv54= Received: from localhost.localdomain.localdomain (unknown [112.10.94.64]) by smtp9 (Coremail) with SMTP id DcCowAD3_i5do9NfaOz1VQ--.33230S2; Sat, 12 Dec 2020 00:50:37 +0800 (CST) From: Jiawei Zhu <17826875952@163.com> To: dev@dpdk.org Date: Wed, 2 Dec 2020 14:32:13 -0500 Message-Id: <1606937533-5235-1-git-send-email-17826875952@163.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1607703293-6121-1-git-send-email-17826875952@163.com> References: <1607703293-6121-1-git-send-email-17826875952@163.com> X-CM-TRANSID: DcCowAD3_i5do9NfaOz1VQ--.33230S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxJr18ZF1rWryxAFWkZrW3Awb_yoW8GF4DpF 4UuFs3Xry7Gry2k3WrJ3WDWa45Zas3Gw47Gr95Xwn5CrZ5Ar15ArW8Aa4Ykr17AryDAFW7 tr109F15trZxuaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UQBMiUUUUU= X-Originating-IP: [112.10.94.64] X-CM-SenderInfo: bprxmjywyxkmivs6il2tof0z/xtbBERr39laEB+l8VQABse Subject: [dpdk-dev] [PATCH v2] net/virtio-user: fix run close(0) and close callfd 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" From: Jiawei Zhu When i < VIRTIO_MAX_VIRTQUEUES and j == i, dev->callfds[i] and dev->kickfds[i] are default 0. So it will close(0), close the standard input (stdin). And when the code fails in kickfd creation, it will leaves one callfd not closed. Fixes: e6e7ad8b3024 ("net/virtio-user: move eventfd open/close into init/uninit") Cc: stable@dpdk.org: Signed-off-by: Jiawei Zhu --- v2: * Add close callfd when fail in kickfd creation before break. --- --- drivers/net/virtio/virtio_user/virtio_user_dev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index 053f026..e1cbad0 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -276,6 +276,7 @@ int virtio_user_stop_device(struct virtio_user_dev *dev) } kickfd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); if (kickfd < 0) { + close(callfd); PMD_DRV_LOG(ERR, "kickfd error, %s", strerror(errno)); break; } @@ -284,7 +285,7 @@ int virtio_user_stop_device(struct virtio_user_dev *dev) } if (i < VIRTIO_MAX_VIRTQUEUES) { - for (j = 0; j <= i; ++j) { + for (j = 0; j < i; ++j) { close(dev->callfds[j]); close(dev->kickfds[j]); } -- 1.8.3.1