Commit 05913cc4 authored by Johan Hovold's avatar Johan Hovold Committed by Joerg Roedel
Browse files

iommu/exynos: fix device leak on of_xlate()



Make sure to drop the reference taken to the iommu platform device when
looking up its driver data during of_xlate().

Note that commit 1a260449 ("iommu/exynos: add missing put_device()
call in exynos_iommu_of_xlate()") fixed the leak in a couple of error
paths, but the reference is still leaking on success.

Fixes: aa759fd3 ("iommu/exynos: Add callback for initializing devices from device tree")
Cc: stable@vger.kernel.org	# 4.2: 1a260449
Cc: Yu Kuai <yukuai3@huawei.com>
Acked-by: default avatarRobin Murphy <robin.murphy@arm.com>
Acked-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Signed-off-by: default avatarJoerg Roedel <joerg.roedel@amd.com>
parent 6a3908ce
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -1446,17 +1446,14 @@ static int exynos_iommu_of_xlate(struct device *dev,
		return -ENODEV;

	data = platform_get_drvdata(sysmmu);
	if (!data) {
	put_device(&sysmmu->dev);
	if (!data)
		return -ENODEV;
	}

	if (!owner) {
		owner = kzalloc(sizeof(*owner), GFP_KERNEL);
		if (!owner) {
			put_device(&sysmmu->dev);
		if (!owner)
			return -ENOMEM;
		}

		INIT_LIST_HEAD(&owner->controllers);
		mutex_init(&owner->rpm_lock);