Commit ab31cf04 authored by Johan Hovold's avatar Johan Hovold Committed by Joerg Roedel
Browse files

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: default avatarRobin Murphy <robin.murphy@arm.com>
Reviewed-by: default avatarYong Wu <yong.wu@mediatek.com>
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: default avatarJoerg Roedel <joerg.roedel@amd.com>
parent 46207625
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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;