From: Johan Hovold Date: Mon, 20 Oct 2025 04:53:14 +0000 (+0200) Subject: iommu/mediatek-v1: add missing larb count sanity check X-Git-Tag: v6.19-rc1~133^2^8~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ab31cf041e4916bdf5c6b60a5286521c806a7033;p=thirdparty%2Fkernel%2Flinux.git 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 --- 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;