Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 1a26044954a6 ("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: aa759fd376fb ("iommu/exynos: Add callback for initializing devices from device tree")
Cc: stable@vger.kernel.org # 4.2: 1a26044954a6
Cc: Yu Kuai <yukuai3@huawei.com>
Acked-by: Robin Murphy <robin.murphy@arm.com>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>

authored by

Johan Hovold and committed by
Joerg Roedel
05913cc4 6a3908ce

+3 -6
+3 -6
drivers/iommu/exynos-iommu.c
··· 1446 1446 return -ENODEV; 1447 1447 1448 1448 data = platform_get_drvdata(sysmmu); 1449 - if (!data) { 1450 - put_device(&sysmmu->dev); 1449 + put_device(&sysmmu->dev); 1450 + if (!data) 1451 1451 return -ENODEV; 1452 - } 1453 1452 1454 1453 if (!owner) { 1455 1454 owner = kzalloc(sizeof(*owner), GFP_KERNEL); 1456 - if (!owner) { 1457 - put_device(&sysmmu->dev); 1455 + if (!owner) 1458 1456 return -ENOMEM; 1459 - } 1460 1457 1461 1458 INIT_LIST_HEAD(&owner->controllers); 1462 1459 mutex_init(&owner->rpm_lock);