[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251209113333.1086-1-vulab@iscas.ac.cn>
Date: Tue, 9 Dec 2025 19:33:32 +0800
From: Haotian Zhang <vulab@...as.ac.cn>
To: Joerg Roedel <joro@...tes.org>,
Will Deacon <will@...nel.org>,
Heiko Stuebner <heiko@...ech.de>
Cc: Robin Murphy <robin.murphy@....com>,
iommu@...ts.linux.dev,
linux-arm-kernel@...ts.infradead.org,
linux-rockchip@...ts.infradead.org,
linux-kernel@...r.kernel.org,
Haotian Zhang <vulab@...as.ac.cn>
Subject: [PATCH] iommu/rockchip: Check of_find_device_by_node() return value
rk_iommu_of_xlate() calls of_find_device_by_node() without
verifying it is non-NULL, which can lead to a NULL pointer
dereference and crash.
Add a check for a NULL return from of_find_device_by_node()
and return -ENODEV upon failure.
Fixes: 5fd577c3eac3 ("iommu/rockchip: Use OF_IOMMU to attach devices automatically")
Signed-off-by: Haotian Zhang <vulab@...as.ac.cn>
---
drivers/iommu/rockchip-iommu.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c
index 0861dd469bd8..e59d0617574b 100644
--- a/drivers/iommu/rockchip-iommu.c
+++ b/drivers/iommu/rockchip-iommu.c
@@ -1153,6 +1153,8 @@ 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)
--
2.50.1.windows.1
Powered by blists - more mailing lists