summaryrefslogtreecommitdiffstats
path: root/drivers/vfio/platform
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert+renesas@glider.be>2018-04-11 11:15:48 +0200
committerAlex Williamson <alex.williamson@redhat.com>2018-06-08 18:24:20 +0200
commit28a68387888997e8a7fa57940ea5d55f2e16b594 (patch)
tree96851056a21bfba4ea04af2f8ff3ce3c4b51b66e /drivers/vfio/platform
parentsample: vfio bochs vbe display (host device for bochs-drm) (diff)
downloadlinux-28a68387888997e8a7fa57940ea5d55f2e16b594.tar.xz
linux-28a68387888997e8a7fa57940ea5d55f2e16b594.zip
vfio: platform: Fix reset module leak in error path
If the IOMMU group setup fails, the reset module is not released. Fixes: b5add544d677d363 ("vfio, platform: make reset driver a requirement by default") Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Eric Auger <eric.auger@redhat.com> Reviewed-by: Simon Horman <horms+renesas@verge.net.au> Acked-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'drivers/vfio/platform')
-rw-r--r--drivers/vfio/platform/vfio_platform_common.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c
index 4c27f4be3c3d..aa9e792110e3 100644
--- a/drivers/vfio/platform/vfio_platform_common.c
+++ b/drivers/vfio/platform/vfio_platform_common.c
@@ -681,18 +681,23 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
group = vfio_iommu_group_get(dev);
if (!group) {
pr_err("VFIO: No IOMMU group for device %s\n", vdev->name);
- return -EINVAL;
+ ret = -EINVAL;
+ goto put_reset;
}
ret = vfio_add_group_dev(dev, &vfio_platform_ops, vdev);
- if (ret) {
- vfio_iommu_group_put(group, dev);
- return ret;
- }
+ if (ret)
+ goto put_iommu;
mutex_init(&vdev->igate);
return 0;
+
+put_iommu:
+ vfio_iommu_group_put(group, dev);
+put_reset:
+ vfio_platform_put_reset(vdev);
+ return ret;
}
EXPORT_SYMBOL_GPL(vfio_platform_probe_common);