Skip to content

Commit

Permalink
net/virtio-user: fix run closing stdin and close callfd
Browse files Browse the repository at this point in the history
[ upstream commit 97ed740 ]

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: e6e7ad8 ("net/virtio-user: move eventfd open/close into init/uninit")
Cc: stable@dpdk.org:

Signed-off-by: Jiawei Zhu <zhujiawei12@huawei.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
  • Loading branch information
Jiawei Zhu authored and bluca committed Feb 2, 2021
1 parent 0be706e commit c778b2b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/net/virtio/virtio_user/virtio_user_dev.c
Expand Up @@ -276,6 +276,7 @@ virtio_user_dev_init_notify(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;
}
Expand All @@ -284,7 +285,7 @@ virtio_user_dev_init_notify(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]);
}
Expand Down

0 comments on commit c778b2b

Please sign in to comment.