From fa8053841efebab7fcdc76252b953f8dafe7a343 Mon Sep 17 00:00:00 2001 From: Zhenzhong Duan Date: Wed, 22 May 2024 19:01:06 +0200 Subject: [PATCH] vfio/ccw: Fix the missed unrealize() call in error path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When get name failed, we should call unrealize() so that vfio_ccw_realize() is self contained. Fixes: 909a6254eda ("vfio/ccw: Make vfio cdev pre-openable by passing a file handle") Signed-off-by: Zhenzhong Duan Reviewed-by: Cédric Le Goater Reviewed-by: Eric Farman Reviewed-by: Thomas Huth Message-ID: <20240522170107.289532-7-clg@redhat.com> Signed-off-by: Thomas Huth --- hw/vfio/ccw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index a468fa2342..36f2677a44 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -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); }