vfio/ccw: Fix the missed unrealize() call in error path

When get name failed, we should call unrealize() so that
vfio_ccw_realize() is self contained.

Fixes: 909a6254ed ("vfio/ccw: Make vfio cdev pre-openable by passing a file handle")
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20240522170107.289532-7-clg@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
Zhenzhong Duan 2024-05-22 19:01:06 +02:00 committed by Thomas Huth
parent 1aeebbd621
commit fa8053841e

View File

@ -588,7 +588,7 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp)
}
if (!vfio_device_get_name(vbasedev, errp)) {
return;
goto out_unrealize;
}
if (!vfio_attach_device(cdev->mdevid, vbasedev,
@ -631,6 +631,7 @@ out_region_err:
vfio_detach_device(vbasedev);
out_attach_dev_err:
g_free(vbasedev->name);
out_unrealize:
if (cdc->unrealize) {
cdc->unrealize(cdev);
}