From ab31cf041e4916bdf5c6b60a5286521c806a7033 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Mon, 20 Oct 2025 06:53:14 +0200 Subject: [PATCH] iommu/mediatek-v1: add missing larb count sanity check Add the missing larb count sanity check to avoid writing beyond a fixed sized array in case of a malformed devicetree. Acked-by: Robin Murphy Reviewed-by: Yong Wu Signed-off-by: Johan Hovold Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Joerg Roedel --- drivers/iommu/mtk_iommu_v1.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c index 86686455e911b..c8d8eff5373d3 100644 --- a/drivers/iommu/mtk_iommu_v1.c +++ b/drivers/iommu/mtk_iommu_v1.c @@ -646,6 +646,9 @@ static int mtk_iommu_v1_probe(struct platform_device *pdev) if (larb_nr < 0) return larb_nr; + if (larb_nr > MTK_LARB_NR_MAX) + return -EINVAL; + for (i = 0; i < larb_nr; i++) { struct device_node *larbnode; struct platform_device *plarbdev; -- 2.47.3