In mtk_iommu_mm_dts_parse(), frst_avail_smicomm_node holds an OF node reference acquired via of_parse_phandle() on the first valid larb iteration. If any subsequent iteration fails and jumps to err_larbdev_put, the error path releases data->larb_imu[] devices but never calls of_node_put(frst_avail_smicomm_node), leaking the OF node reference. Clear frst_avail_smicomm_node after its normal-path of_node_put() and call of_node_put(frst_avail_smicomm_node) on the err_larbdev_put path. Found by LLM-assisted static analysis. Compile-tested on x86_64. Fixes: 6cde583d5352 ("iommu/mediatek: Improve safety for mediatek,smi property in larb nodes") Cc: stable@vger.kernel.org Signed-off-by: Ziheng Wei --- drivers/iommu/mtk_iommu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index e3d471701..0e039593e 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -1265,6 +1265,7 @@ static int mtk_iommu_mm_dts_parse(struct device *dev, struct component_match **m pcommdev = of_find_device_by_node(frst_avail_smicomm_node); of_node_put(frst_avail_smicomm_node); + frst_avail_smicomm_node = NULL; if (!pcommdev) { ret = -ENODEV; goto err_larbdev_put; @@ -1282,6 +1283,7 @@ static int mtk_iommu_mm_dts_parse(struct device *dev, struct component_match **m return 0; err_larbdev_put: + of_node_put(frst_avail_smicomm_node); /* 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); base-commit: 97d73c8251226cf27cc6656b4c542869bb8c69fa -- 2.43.0