Skip to content

Commit f05c7b7

Browse files
Kang Chendlezcano
authored andcommitted
thermal/drivers/mediatek: Use devm_of_iomap to avoid resource leak in mtk_thermal_probe
Smatch reports: 1. mtk_thermal_probe() warn: 'apmixed_base' from of_iomap() not released. 2. mtk_thermal_probe() warn: 'auxadc_base' from of_iomap() not released. The original code forgets to release iomap resource when handling errors, fix it by switch to devm_of_iomap. Fixes: 8994504 ("thermal: mediatek: Add tsensor support for V2 thermal system") Signed-off-by: Kang Chen <void0red@hust.edu.cn> Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20230419020749.621257-1-void0red@hust.edu.cn
1 parent 47cbb04 commit f05c7b7

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

drivers/thermal/mediatek/auxadc_thermal.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,12 @@ static int mtk_thermal_probe(struct platform_device *pdev)
12321232
return -ENODEV;
12331233
}
12341234

1235-
auxadc_base = of_iomap(auxadc, 0);
1235+
auxadc_base = devm_of_iomap(&pdev->dev, auxadc, 0, NULL);
1236+
if (IS_ERR(auxadc_base)) {
1237+
of_node_put(auxadc);
1238+
return PTR_ERR(auxadc_base);
1239+
}
1240+
12361241
auxadc_phys_base = of_get_phys_base(auxadc);
12371242

12381243
of_node_put(auxadc);
@@ -1248,7 +1253,12 @@ static int mtk_thermal_probe(struct platform_device *pdev)
12481253
return -ENODEV;
12491254
}
12501255

1251-
apmixed_base = of_iomap(apmixedsys, 0);
1256+
apmixed_base = devm_of_iomap(&pdev->dev, apmixedsys, 0, NULL);
1257+
if (IS_ERR(apmixed_base)) {
1258+
of_node_put(apmixedsys);
1259+
return PTR_ERR(apmixed_base);
1260+
}
1261+
12521262
apmixed_phys_base = of_get_phys_base(apmixedsys);
12531263

12541264
of_node_put(apmixedsys);

0 commit comments

Comments
 (0)