Skip to content

Commit 74af5ee

Browse files
jasowangmstsirkin
authored andcommitted
vhost-vdpa: fix the wrong assertion in vhost_vdpa_init()
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 <[email protected]> Signed-off-by: Jason Wang <[email protected]> Message-Id: <[email protected]> Reviewed-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent a97ef87 commit 74af5ee

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

net/vhost-vdpa.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,10 @@ static int net_vhost_vdpa_init(NetClientState *peer, const char *device,
173173
}
174174
s->vhost_vdpa.device_fd = vdpa_device_fd;
175175
ret = vhost_vdpa_add(nc, (void *)&s->vhost_vdpa);
176-
assert(s->vhost_net);
176+
if (ret) {
177+
qemu_close(vdpa_device_fd);
178+
qemu_del_net_client(nc);
179+
}
177180
return ret;
178181
}
179182

0 commit comments

Comments
 (0)