]> Gentwo Git Trees - linux/.git/commitdiff
iommu/mediatek: simplify dt parsing error handling
authorJohan Hovold <johan@kernel.org>
Mon, 20 Oct 2025 04:53:11 +0000 (06:53 +0200)
committerJoerg Roedel <joerg.roedel@amd.com>
Mon, 17 Nov 2025 08:49:43 +0000 (09:49 +0100)
As previously documented by commit 26593928564c ("iommu/mediatek: Add
error path for loop of mm_dts_parse"), the id mapping may not be linear
so the whole larb array needs to be iterated on devicetree parsing
errors.

Simplify the loop by iterating from index zero while dropping the
redundant NULL check for consistency with later cleanups.

Also add back the comment which was removed by commit 462e768b55a2
("iommu/mediatek: Fix forever loop in error handling") to prevent anyone
from trying to optimise the loop by iterating backwards from 'i'.

Cc: Yong Wu <yong.wu@mediatek.com>
Acked-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Yong Wu <yong.wu@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
drivers/iommu/mtk_iommu.c

index 54d8936d9d11ada271702486993174b52b632525..657a443ad23aca5586cd6384c75d65f6857c8d6c 100644 (file)
@@ -1239,11 +1239,10 @@ static int mtk_iommu_mm_dts_parse(struct device *dev, struct component_match **m
        return 0;
 
 err_larbdev_put:
-       for (i = MTK_LARB_NR_MAX - 1; i >= 0; i--) {
-               if (!data->larb_imu[i].dev)
-                       continue;
+       /* id mapping may not be linear, loop the whole array */
+       for (i = 0; i < MTK_LARB_NR_MAX; i++)
                put_device(data->larb_imu[i].dev);
-       }
+
        return ret;
 }