[PATCH] iommu/rockchip: Fix device reference leak in rk_iommu_of_xlate()

From: Xiangwu Lai

Date: Wed Nov 11 2026 - 21:24:25 EST


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@xxxxxxxxxxxxxxxxxxxx>
---
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