From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (xvm-189-124.dc0.ghst.net [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DCA5AA0524 for ; Thu, 7 Jan 2021 11:36:14 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B4B77140F1B; Thu, 7 Jan 2021 11:36:14 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mails.dpdk.org (Postfix) with ESMTP id 47ECF140F1B for ; Thu, 7 Jan 2021 11:36:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610015772; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZmSJi4zsgkgedOoEiZu+yLysxDo0fWgpRmgvtywGuC8=; b=K31fTY1jzIoeaTzryL5/TZjPTyxSDn3jlShj8KD3AzWIAPxTjES6jIK2KcWOjZuFKFbMOK DYc0MbFglXBdVnszkpFrw+CiEDFyKYNk3Rc94sx8xa9MYmfLUFXdZBzetXm2cR4kV02FWM t5BKicOkdi/g4uwT6OtPWJhnulfkUus= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-538--7yo26TtPDytmtoXgpPi4A-1; Thu, 07 Jan 2021 05:36:10 -0500 X-MC-Unique: -7yo26TtPDytmtoXgpPi4A-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DB73810054FF; Thu, 7 Jan 2021 10:36:09 +0000 (UTC) Received: from [10.36.110.9] (unknown [10.36.110.9]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D8DD210013C0; Thu, 7 Jan 2021 10:36:08 +0000 (UTC) To: Jiawei Zhu <17826875952@163.com>, dev@dpdk.org References: <1607703293-6121-1-git-send-email-17826875952@163.com> <1607706688-9839-1-git-send-email-17826875952@163.com> Cc: "stable@dpdk.org" From: Maxime Coquelin Message-ID: <8c867a91-d8c9-013d-6ef2-be98f1e2f967@redhat.com> Date: Thu, 7 Jan 2021 11:36:06 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <1607706688-9839-1-git-send-email-17826875952@163.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH v2] net/virtio-user: fix run close(0) and close callfd X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Cc'ing stable@dpdk.org. On 12/11/20 6:11 PM, Jiawei Zhu wrote: > 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]); > } > Reviewed-by: Maxime Coquelin Thanks! Maxime