DPDK patches and discussions
 help / color / mirror / Atom feed
From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: Jiawei Zhu <17826875952@163.com>, dev@dpdk.org
Cc: "stable@dpdk.org" <stable@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v2] net/virtio-user: fix run close(0) and close callfd
Date: Thu, 7 Jan 2021 11:36:06 +0100	[thread overview]
Message-ID: <8c867a91-d8c9-013d-6ef2-be98f1e2f967@redhat.com> (raw)
In-Reply-To: <1607706688-9839-1-git-send-email-17826875952@163.com>

Cc'ing stable@dpdk.org.

On 12/11/20 6:11 PM, Jiawei Zhu wrote:
> From: Jiawei Zhu <zhujiawei12@huawei.com>
> 
> 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 <zhujiawei12@huawei.com>
> ---
> 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 <maxime.coquelin@redhat.com>

Thanks!
Maxime


  reply	other threads:[~2021-01-07 10:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-11 16:14 Jiawei Zhu
2020-12-02 19:32 ` Jiawei Zhu
2020-12-11 16:53 ` Jiawei Zhu
2020-12-14 13:02   ` Xia, Chenbo
2020-12-11 17:08 ` Jiawei Zhu
2020-12-11 17:11 ` Jiawei Zhu
2021-01-07 10:36   ` Maxime Coquelin [this message]
2021-01-08  9:14   ` Maxime Coquelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8c867a91-d8c9-013d-6ef2-be98f1e2f967@redhat.com \
    --to=maxime.coquelin@redhat.com \
    --cc=17826875952@163.com \
    --cc=dev@dpdk.org \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).