Skip to content

Commit

Permalink
vhost-scsi: Call virtio_scsi_common_unrealize() when device realize f…
Browse files Browse the repository at this point in the history
…ailed

This avoids memory leak when device hotplug is failed.

Signed-off-by: Xie Yongji <xieyongji@baidu.com>
Message-Id: <20190717004606.12444-1-xieyongji@baidu.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Xie Yongji authored and bonzini committed Jul 19, 2019
1 parent 12e1dc4 commit 934443c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion hw/scsi/vhost-scsi.c
Expand Up @@ -210,7 +210,7 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
if (err) {
error_propagate(errp, err);
error_free(vsc->migration_blocker);
goto close_fd;
goto free_virtio;
}
}

Expand Down Expand Up @@ -240,6 +240,8 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
migrate_del_blocker(vsc->migration_blocker);
}
g_free(vsc->dev.vqs);
free_virtio:
virtio_scsi_common_unrealize(dev);
close_fd:
close(vhostfd);
return;
Expand Down

0 comments on commit 934443c

Please sign in to comment.