mirror of https://github.com/xemu-project/xemu.git
hw/scsi/vhost-scsi: don't double close vhostfd on error
vhost_dev_init calls vhost_dev_cleanup on error, which closes vhostfd, don't double close it. Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru> Message-Id: <20211129132358.1110372-2-d-tatianin@yandex-team.ru> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
b259772afc
commit
539ba1acac
|
@ -222,6 +222,11 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
|
||||||
ret = vhost_dev_init(&vsc->dev, (void *)(uintptr_t)vhostfd,
|
ret = vhost_dev_init(&vsc->dev, (void *)(uintptr_t)vhostfd,
|
||||||
VHOST_BACKEND_TYPE_KERNEL, 0, errp);
|
VHOST_BACKEND_TYPE_KERNEL, 0, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
/*
|
||||||
|
* vhost_dev_init calls vhost_dev_cleanup on error, which closes
|
||||||
|
* vhostfd, don't double close it.
|
||||||
|
*/
|
||||||
|
vhostfd = -1;
|
||||||
goto free_vqs;
|
goto free_vqs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,7 +247,9 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
|
||||||
error_free(vsc->migration_blocker);
|
error_free(vsc->migration_blocker);
|
||||||
virtio_scsi_common_unrealize(dev);
|
virtio_scsi_common_unrealize(dev);
|
||||||
close_fd:
|
close_fd:
|
||||||
|
if (vhostfd >= 0) {
|
||||||
close(vhostfd);
|
close(vhostfd);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue