Skip to content

Commit 73b6924

Browse files
Yang Yingliangjoergroedel
authored andcommitted
iommu/mediatek: Check return value after calling platform_get_resource()
platform_get_resource() may return NULL pointer, we need check its return value to avoid null-ptr-deref in resource_size(). Fixes: 42d57fc ("iommu/mediatek: Initialise/Remove for multi bank dev") Signed-off-by: Yang Yingliang <[email protected]> Reviewed-by: Matthias Brugger <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 30a0b95 commit 73b6924

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/iommu/mtk_iommu.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,8 @@ static int mtk_iommu_probe(struct platform_device *pdev)
11731173

11741174
banks_num = data->plat_data->banks_num;
11751175
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1176+
if (!res)
1177+
return -EINVAL;
11761178
if (resource_size(res) < banks_num * MTK_IOMMU_BANK_SZ) {
11771179
dev_err(dev, "banknr %d. res %pR is not enough.\n", banks_num, res);
11781180
return -EINVAL;

0 commit comments

Comments
 (0)