[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240425091813.965003-1-nichen@iscas.ac.cn>
Date: Thu, 25 Apr 2024 17:18:13 +0800
From: Chen Ni <nichen@...as.ac.cn>
To: joro@...tes.org,
will@...nel.org,
robin.murphy@....com,
heiko@...ech.de,
jeffy.chen@...k-chips.com
Cc: iommu@...ts.linux.dev,
linux-arm-kernel@...ts.infradead.org,
linux-rockchip@...ts.infradead.org,
linux-kernel@...r.kernel.org,
Chen Ni <nichen@...as.ac.cn>
Subject: [PATCH] iommu/rockchip: Add missing check for of_find_device_by_node
Add check for the return value of of_find_device_by_node() and return
the error if it fails in order to avoid NULL pointer dereference.
Fixes: 5fd577c3eac3 ("iommu/rockchip: Use OF_IOMMU to attach devices automatically")
Signed-off-by: Chen Ni <nichen@...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 4b369419b32c..1225c1df6ef6 100644
--- a/drivers/iommu/rockchip-iommu.c
+++ b/drivers/iommu/rockchip-iommu.c
@@ -1152,6 +1152,8 @@ static int rk_iommu_of_xlate(struct device *dev,
return -ENOMEM;
iommu_dev = of_find_device_by_node(args->np);
+ if (!iommu_dev)
+ return -ENODEV;
data->iommu = platform_get_drvdata(iommu_dev);
data->iommu->domain = &rk_identity_domain;
--
2.25.1
Powered by blists - more mailing lists