[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 19/41] vhost-net: always call vhost_dev_cleanup() on
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 19/41] vhost-net: always call vhost_dev_cleanup() on failure |
Date: |
Fri, 29 Jul 2016 06:16:10 +0300 |
From: Marc-André Lureau <address@hidden>
vhost_dev_init(), calling vhost backend initialization, should be
cleaned up after failure too. Call vhost_dev_cleanup() in all failure
cases. First, it needs to zero-alloc the struct to avoid the initial
garbage.
Signed-off-by: Marc-André Lureau <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
hw/net/vhost_net.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 3677a82..c11f69c 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -140,7 +140,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options)
{
int r;
bool backend_kernel = options->backend_type == VHOST_BACKEND_TYPE_KERNEL;
- struct vhost_net *net = g_malloc(sizeof *net);
+ struct vhost_net *net = g_new0(struct vhost_net, 1);
uint64_t features = 0;
if (!options->net_backend) {
@@ -185,7 +185,6 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options)
fprintf(stderr, "vhost lacks feature mask %" PRIu64
" for backend\n",
(uint64_t)(~net->dev.features & net->dev.backend_features));
- vhost_dev_cleanup(&net->dev);
goto fail;
}
}
@@ -197,7 +196,6 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options)
fprintf(stderr, "vhost lacks feature mask %" PRIu64
" for backend\n",
(uint64_t)(~net->dev.features & features));
- vhost_dev_cleanup(&net->dev);
goto fail;
}
}
@@ -205,7 +203,9 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options)
vhost_net_ack_features(net, features);
return net;
+
fail:
+ vhost_dev_cleanup(&net->dev);
g_free(net);
return NULL;
}
--
MST
- [Qemu-devel] [PULL 09/41] hw/virtio-pci: fix virtio behaviour, (continued)
- [Qemu-devel] [PULL 09/41] hw/virtio-pci: fix virtio behaviour, Michael S. Tsirkin, 2016/07/28
- [Qemu-devel] [PULL 10/41] virtio: check vring descriptor buffer length, Michael S. Tsirkin, 2016/07/28
- [Qemu-devel] [PULL 11/41] misc: indentation, Michael S. Tsirkin, 2016/07/28
- [Qemu-devel] [PULL 12/41] vhost-user: minor simplification, Michael S. Tsirkin, 2016/07/28
- [Qemu-devel] [PULL 13/41] vhost-user: disconnect on HUP, Michael S. Tsirkin, 2016/07/28
- [Qemu-devel] [PULL 15/41] vhost: make vhost_log_put() idempotent, Michael S. Tsirkin, 2016/07/28
- [Qemu-devel] [PULL 14/41] vhost: don't assume opaque is a fd, use backend cleanup, Michael S. Tsirkin, 2016/07/28
- [Qemu-devel] [PULL 16/41] vhost: assert the log was cleaned up, Michael S. Tsirkin, 2016/07/28
- [Qemu-devel] [PULL 17/41] vhost: fix cleanup on not fully initialized device, Michael S. Tsirkin, 2016/07/28
- [Qemu-devel] [PULL 18/41] vhost: make vhost_dev_cleanup() idempotent, Michael S. Tsirkin, 2016/07/28
- [Qemu-devel] [PULL 19/41] vhost-net: always call vhost_dev_cleanup() on failure,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 20/41] vhost: fix calling vhost_dev_cleanup() after vhost_dev_init(), Michael S. Tsirkin, 2016/07/28
- [Qemu-devel] [PULL 22/41] vhost: add missing VHOST_OPS_DEBUG, Michael S. Tsirkin, 2016/07/28
- [Qemu-devel] [PULL 21/41] vhost: do not assert() on vhost_ops failure, Michael S. Tsirkin, 2016/07/28
- [Qemu-devel] [PULL 23/41] vhost: use error_report() instead of fprintf(stderr, ...), Michael S. Tsirkin, 2016/07/28
- [Qemu-devel] [PULL 24/41] qemu-char: fix qemu_chr_fe_set_msgfds() crash when disconnected, Michael S. Tsirkin, 2016/07/28
- [Qemu-devel] [PULL 25/41] vhost-user: call set_msgfds unconditionally, Michael S. Tsirkin, 2016/07/28
- [Qemu-devel] [PULL 26/41] vhost-user: check qemu_chr_fe_set_msgfds() return value, Michael S. Tsirkin, 2016/07/28
- [Qemu-devel] [PULL 27/41] vhost-user: check vhost_user_{read, write}() return value, Michael S. Tsirkin, 2016/07/28
- [Qemu-devel] [PULL 28/41] vhost-user: keep vhost_net after a disconnection, Michael S. Tsirkin, 2016/07/28
- [Qemu-devel] [PULL 29/41] vhost-user: add get_vhost_net() assertions, Michael S. Tsirkin, 2016/07/28