OSDN Git Service

iommu/mediatek: Add error path for loop of mm_dts_parse
authorYong Wu <yong.wu@mediatek.com>
Tue, 18 Oct 2022 02:42:55 +0000 (10:42 +0800)
committerJoerg Roedel <jroedel@suse.de>
Mon, 5 Dec 2022 10:46:02 +0000 (11:46 +0100)
commit26593928564cf5b576ff05d3cbd958f57c9534bb
tree1a6f8a1412bd2d2760b2100deabdca3d3194498d
parentb5765a1b44bea9dfcae69c53ffeb4c689d0922a7
iommu/mediatek: Add error path for loop of mm_dts_parse

The mtk_iommu_mm_dts_parse will parse the smi larbs nodes. if the i+1
larb is parsed fail, we should put_device for the i..0 larbs.

There are two places need to comment:
1) The larbid may be not linear mapping, we should loop whole
   the array in the error path.
2) I move this line position: "data->larb_imu[id].dev = &plarbdev->dev;"
   before "if (!plarbdev->dev.driver)", That means set
   data->larb_imu[id].dev before the error path. then we don't need
   "platform_device_put(plarbdev)" again in probe_defer case. All depend
   on "put_device" of the error path in error cases.

Fixes: d2e9a1102cfc ("iommu/mediatek: Contain MM IOMMU flow with the MM TYPE")
Signed-off-by: Yong Wu <yong.wu@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
Link: https://lore.kernel.org/r/20221018024258.19073-4-yong.wu@mediatek.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/mtk_iommu.c