All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu/mediatek: check return value after calling platform_get_resource()
@ 2022-10-29 10:35 Yang Yingliang
  2022-11-07 16:03 ` Matthias Brugger
  2022-11-19  9:09 ` Joerg Roedel
  0 siblings, 2 replies; 6+ messages in thread
From: Yang Yingliang @ 2022-10-29 10:35 UTC (permalink / raw)
  To: iommu, linux-mediatek
  Cc: yong.wu, joro, will, robin.murphy, matthias.bgg, yangyingliang

platform_get_resource() may return NULL pointer, we need check its
return value to avoid null-ptr-deref in resource_size().

Fixes: 42d57fc58aeb ("iommu/mediatek: Initialise/Remove for multi bank dev")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/iommu/mtk_iommu.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
index 2ab2ecfe01f8..2d14dc846b83 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -1173,6 +1173,8 @@ static int mtk_iommu_probe(struct platform_device *pdev)
 
 	banks_num = data->plat_data->banks_num;
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -EINVAL;
 	if (resource_size(res) < banks_num * MTK_IOMMU_BANK_SZ) {
 		dev_err(dev, "banknr %d. res %pR is not enough.\n", banks_num, res);
 		return -EINVAL;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [PATCH] iommu/mediatek: check return value after calling platform_get_resource()
@ 2022-07-04  7:59 ` Yang Yingliang
  0 siblings, 0 replies; 6+ messages in thread
From: Yang Yingliang via iommu @ 2022-07-04  7:59 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, linux-mediatek, iommu, iommu

It will cause null-ptr-deref if platform_get_resource() returns NULL,
we need check the return value.

Fixes: 42d57fc58aeb ("iommu/mediatek: Initialise/Remove for multi bank dev")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/iommu/mtk_iommu.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
index b2ae84046249..b45b0c1cfff9 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -1174,6 +1174,8 @@ static int mtk_iommu_probe(struct platform_device *pdev)
 
 	banks_num = data->plat_data->banks_num;
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -EINVAL;
 	if (resource_size(res) < banks_num * MTK_IOMMU_BANK_SZ) {
 		dev_err(dev, "banknr %d. res %pR is not enough.\n", banks_num, res);
 		return -EINVAL;
-- 
2.25.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

end of thread, other threads:[~2022-11-19  9:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-29 10:35 [PATCH] iommu/mediatek: check return value after calling platform_get_resource() Yang Yingliang
2022-11-07 16:03 ` Matthias Brugger
2022-11-19  9:09 ` Joerg Roedel
  -- strict thread matches above, loose matches on Subject: below --
2022-07-04  7:59 Yang Yingliang via iommu
2022-07-04  7:59 ` Yang Yingliang
2022-07-04  7:59 ` Yang Yingliang

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.