Commit cebb63a7 authored by GangCao's avatar GangCao Committed by Tomasz Zawadzki
Browse files

lib/virtio: add the ctx NULL check before dereferencing it



Issue is found in the virtio_pci_scsi_dev_create() whose
error path is setting the vdev->ctx to NULL before the
destruct operation.

Change-Id: I4ab0fbe300f7413ad4503833088856aa3f4c0734
Signed-off-by: default avatarGangCao <gang.cao@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15676


Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent fed1f52b
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -183,9 +183,11 @@ virtio_vfio_user_destruct_dev(struct virtio_dev *vdev)
{
	struct virtio_vfio_user_dev *dev = vdev->ctx;

	if (dev) {
		spdk_vfio_user_release(dev->ctx);
		free(dev);
	}
}

static uint16_t
virtio_vfio_user_get_queue_size(struct virtio_dev *vdev, uint16_t queue_id)
+4 −2
Original line number Diff line number Diff line
@@ -971,9 +971,11 @@ virtio_user_destroy(struct virtio_dev *vdev)
{
	struct virtio_user_dev *dev = vdev->ctx;

	if (dev) {
		close(dev->vhostfd);
		free(dev);
	}
}

static void
virtio_user_dump_json_info(struct virtio_dev *vdev, struct spdk_json_write_ctx *w)