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: GangCao <gang.cao@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15676 Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
fed1f52b9e
commit
cebb63a7a7
@ -183,8 +183,10 @@ 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
|
||||
|
@ -971,8 +971,10 @@ virtio_user_destroy(struct virtio_dev *vdev)
|
||||
{
|
||||
struct virtio_user_dev *dev = vdev->ctx;
|
||||
|
||||
if (dev) {
|
||||
close(dev->vhostfd);
|
||||
free(dev);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user