mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iommu/rockchip: Check of_find_device_by_node() return value
@ 2025-12-09 11:33 Haotian Zhang
  2025-12-09 11:43 ` Robin Murphy
  0 siblings, 1 reply; 2+ messages in thread
From: Haotian Zhang @ 2025-12-09 11:33 UTC (permalink / raw)
  To: Joerg Roedel, Will Deacon, Heiko Stuebner
  Cc: Robin Murphy, iommu, linux-arm-kernel, linux-rockchip,
	linux-kernel, Haotian Zhang

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@iscas.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


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

end of thread, other threads:[~2025-12-09 11:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-09 11:33 [PATCH] iommu/rockchip: Check of_find_device_by_node() return value Haotian Zhang
2025-12-09 11:43 ` Robin Murphy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®