All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu/rockchip: Fix device reference leak in rk_iommu_of_xlate()
@ 2026-11-12  2:18 ` Xiangwu Lai
  0 siblings, 0 replies; 8+ messages in thread
From: Xiangwu Lai @ 2026-11-12  2:18 UTC (permalink / raw)
  To: joro, will
  Cc: robin.murphy, heiko, iommu, linux-rockchip, linux-kernel,
	Xiangwu Lai

rk_iommu_of_xlate() takes a reference on the IOMMU platform device
with of_find_device_by_node(), but when the subsequent per-device
data allocation fails the reference is only dropped on the success
path, so the error path leaks it on every client device whose DT
translation hits the allocation failure.  The platform device is
also dereferenced without a NULL check.

Check the platform device and release the reference on the
allocation failure path.

Fixes: f48dcda8f6a4 ("iommu/rockchip: Allocate per-device data sensibly")
Signed-off-by: Xiangwu Lai <laixiangwu@cmss.chinamobile.com>
---
 drivers/iommu/rockchip-iommu.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c
index 21af2f621..793cbdd6d 100644
--- a/drivers/iommu/rockchip-iommu.c
+++ b/drivers/iommu/rockchip-iommu.c
@@ -1185,10 +1185,14 @@ static int rk_iommu_of_xlate(struct device *dev,
 	struct rk_iommudata *data;
 
 	iommu_dev = of_find_device_by_node(args->np);
+	if (!iommu_dev)
+		return -ENODEV;
 
 	data = devm_kzalloc(&iommu_dev->dev, sizeof(*data), GFP_KERNEL);
-	if (!data)
+	if (!data) {
+		platform_device_put(iommu_dev);
 		return -ENOMEM;
+	}
 
 	data->iommu = platform_get_drvdata(iommu_dev);
 	dev_iommu_priv_set(dev, data);
-- 
2.50.1.windows.1




^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-12-02  6:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-12  2:18 [PATCH] iommu/rockchip: Fix device reference leak in rk_iommu_of_xlate() Xiangwu Lai
2026-11-12  2:18 ` Xiangwu Lai
2026-12-01  7:47 ` Xiangwu Lai
2026-12-01  7:47   ` Xiangwu Lai
2026-12-01 10:34   ` Jörg Rödel
2026-12-01 10:34     ` Jörg Rödel
2026-12-02  6:36     ` Xiangwu Lai
2026-12-02  6:36       ` Xiangwu Lai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.