virtio: fix scsi double free issue
During virtio_pci_dev_probe, if enum_cb fails, hw needs to be released. But in bdev_virtio, if vdev fails after initialization, it will enter the bdev destruction process which call the modern_destruct_dev function and hw will be released during the process. So we will encounter the problem of hw being released twice. Change-Id: I1e8116283cfd810dfb050f8928f4ecd4bb2d815b Signed-off-by: Jin Yu <jin.yu@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3566 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
79c7744efb
commit
7ef6d8dd63
@ -344,19 +344,21 @@ virtio_pci_scsi_dev_create(const char *name, struct virtio_pci_ctx *pci_ctx)
|
|||||||
&num_queues, sizeof(num_queues));
|
&num_queues, sizeof(num_queues));
|
||||||
if (rc) {
|
if (rc) {
|
||||||
SPDK_ERRLOG("%s: config read failed: %s\n", vdev->name, spdk_strerror(-rc));
|
SPDK_ERRLOG("%s: config read failed: %s\n", vdev->name, spdk_strerror(-rc));
|
||||||
virtio_dev_destruct(vdev);
|
goto fail;
|
||||||
free(svdev);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = virtio_scsi_dev_init(svdev, num_queues);
|
rc = virtio_scsi_dev_init(svdev, num_queues);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
virtio_dev_destruct(vdev);
|
goto fail;
|
||||||
free(svdev);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return svdev;
|
return svdev;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
vdev->ctx = NULL;
|
||||||
|
virtio_dev_destruct(vdev);
|
||||||
|
free(svdev);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct virtio_scsi_dev *
|
static struct virtio_scsi_dev *
|
||||||
@ -1967,6 +1969,7 @@ bdev_virtio_pci_scsi_dev_create_cb(struct virtio_pci_ctx *pci_ctx, void *ctx)
|
|||||||
|
|
||||||
rc = virtio_scsi_dev_scan(svdev, create_ctx->cb_fn, create_ctx->cb_arg);
|
rc = virtio_scsi_dev_scan(svdev, create_ctx->cb_fn, create_ctx->cb_arg);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
|
svdev->vdev.ctx = NULL;
|
||||||
virtio_scsi_dev_remove(svdev, NULL, NULL);
|
virtio_scsi_dev_remove(svdev, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user