aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert+renesas@glider.be>2018-04-11 05:15:48 -0400
committerAlex Williamson <alex.williamson@redhat.com>2018-06-08 12:24:20 -0400
commit28a68387888997e8a7fa57940ea5d55f2e16b594 (patch)
tree96851056a21bfba4ea04af2f8ff3ce3c4b51b66e
parenta5e6e6505f38f7bce1d3576503a2bffff3fa888c (diff)
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>
-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,
681 group = vfio_iommu_group_get(dev); 681 group = vfio_iommu_group_get(dev);
682 if (!group) { 682 if (!group) {
683 pr_err("VFIO: No IOMMU group for device %s\n", vdev->name); 683 pr_err("VFIO: No IOMMU group for device %s\n", vdev->name);
684 return -EINVAL; 684 ret = -EINVAL;
685 goto put_reset;
685 } 686 }
686 687
687 ret = vfio_add_group_dev(dev, &vfio_platform_ops, vdev); 688 ret = vfio_add_group_dev(dev, &vfio_platform_ops, vdev);
688 if (ret) { 689 if (ret)
689 vfio_iommu_group_put(group, dev); 690 goto put_iommu;
690 return ret;
691 }
692 691
693 mutex_init(&vdev->igate); 692 mutex_init(&vdev->igate);
694 693
695 return 0; 694 return 0;
695
696put_iommu:
697 vfio_iommu_group_put(group, dev);
698put_reset:
699 vfio_platform_put_reset(vdev);
700 return ret;
696} 701}
697EXPORT_SYMBOL_GPL(vfio_platform_probe_common); 702EXPORT_SYMBOL_GPL(vfio_platform_probe_common);
698 703