[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 34/35] vhost-vdpa: fix the wrong assertion in vhost_vdpa_init()
From: |
Michael S. Tsirkin |
Subject: |
[PULL 34/35] vhost-vdpa: fix the wrong assertion in vhost_vdpa_init() |
Date: |
Sat, 4 Sep 2021 17:37:37 -0400 |
From: Jason Wang <jasowang@redhat.com>
Vhost_vdpa_add() can fail for various reasons, so the assertion of the
succeed is wrong. Instead, we should free the NetClientState and
propagate the error to the caller
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Message-Id: <20210903091031.47303-11-jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
net/vhost-vdpa.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index 99327d17b4..d02cad9855 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -173,7 +173,10 @@ static int net_vhost_vdpa_init(NetClientState *peer, const
char *device,
}
s->vhost_vdpa.device_fd = vdpa_device_fd;
ret = vhost_vdpa_add(nc, (void *)&s->vhost_vdpa);
- assert(s->vhost_net);
+ if (ret) {
+ qemu_close(vdpa_device_fd);
+ qemu_del_net_client(nc);
+ }
return ret;
}
--
MST
- [PULL 23/35] tests/vhost-user-bridge.c: Sanity check socket path length, (continued)
- [PULL 23/35] tests/vhost-user-bridge.c: Sanity check socket path length, Michael S. Tsirkin, 2021/09/04
- [PULL 24/35] tests/vhost-user-bridge.c: Fix typo in help message, Michael S. Tsirkin, 2021/09/04
- [PULL 25/35] vhost-vdpa: remove unused variable "acked_features", Michael S. Tsirkin, 2021/09/04
- [PULL 26/35] vhost-vdpa: correctly return err in vhost_vdpa_set_backend_cap(), Michael S. Tsirkin, 2021/09/04
- [PULL 27/35] vhost_net: remove the meaningless assignment in vhost_net_start_one(), Michael S. Tsirkin, 2021/09/04
- [PULL 28/35] vhost: use unsigned int for nvqs, Michael S. Tsirkin, 2021/09/04
- [PULL 29/35] vhost_net: do not assume nvqs is always 2, Michael S. Tsirkin, 2021/09/04
- [PULL 30/35] vhost-vdpa: remove the unnecessary check in vhost_vdpa_add(), Michael S. Tsirkin, 2021/09/04
- [PULL 31/35] vhost-vdpa: don't cleanup twice in vhost_vdpa_add(), Michael S. Tsirkin, 2021/09/04
- [PULL 33/35] vhost-vdpa: tweak the error label in vhost_vdpa_add(), Michael S. Tsirkin, 2021/09/04
- [PULL 34/35] vhost-vdpa: fix the wrong assertion in vhost_vdpa_init(),
Michael S. Tsirkin <=
- [PULL 35/35] vhost-vdpa: remove the unncessary queue_index assignment, Michael S. Tsirkin, 2021/09/04
- [PULL 08/35] vhost-user: add missing space in error message, Michael S. Tsirkin, 2021/09/04
- [PULL 15/35] vhost: correctly detect the enabling IOMMU, Michael S. Tsirkin, 2021/09/04
- [PULL 32/35] vhost-vdpa: fix leaking of vhost_net in vhost_vdpa_add(), Michael S. Tsirkin, 2021/09/04
- Re: [PULL 00/35] pc,pci,virtio: fixes, cleanups, Peter Maydell, 2021/09/06