* [PATCH] thermal: mediatek: Fix some leaks in mtk_thermal_probe
@ 2022-03-07 11:34 Miaoqian Lin
2022-03-08 5:36 ` Miles Chen
0 siblings, 1 reply; 2+ messages in thread
From: Miaoqian Lin @ 2022-03-07 11:34 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui,
Matthias Brugger, Henry Yen, linux-pm, linux-arm-kernel,
linux-mediatek, linux-kernel
Cc: linmq006
If an error occurs after a successful 'of_iomap()' call, it must be undone
by a corresponding 'iounmap()' call
Fixes: 89945047b166 ("thermal: mediatek: Add tsensor support for V2 thermal system")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
drivers/thermal/mtk_thermal.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
index ede94eadddda..9d7461a5c2c1 100644
--- a/drivers/thermal/mtk_thermal.c
+++ b/drivers/thermal/mtk_thermal.c
@@ -1035,13 +1035,15 @@ static int mtk_thermal_probe(struct platform_device *pdev)
if (auxadc_phys_base == OF_BAD_ADDR) {
dev_err(&pdev->dev, "Can't get auxadc phys address\n");
- return -EINVAL;
+ ret = -EINVAL;
+ goto err_umap_auxadc;
}
apmixedsys = of_parse_phandle(np, "mediatek,apmixedsys", 0);
if (!apmixedsys) {
dev_err(&pdev->dev, "missing apmixedsys node\n");
- return -ENODEV;
+ ret = -ENODEV;
+ goto err_umap_auxadc;
}
apmixed_base = of_iomap(apmixedsys, 0);
@@ -1051,17 +1053,18 @@ static int mtk_thermal_probe(struct platform_device *pdev)
if (apmixed_phys_base == OF_BAD_ADDR) {
dev_err(&pdev->dev, "Can't get auxadc phys address\n");
- return -EINVAL;
+ ret = -EINVAL;
+ goto err_umap_apmixed;
}
ret = device_reset_optional(&pdev->dev);
if (ret)
- return ret;
+ goto err_umap_apmixed;
ret = clk_prepare_enable(mt->clk_auxadc);
if (ret) {
dev_err(&pdev->dev, "Can't enable auxadc clk: %d\n", ret);
- return ret;
+ goto err_umap_apmixed;
}
ret = clk_prepare_enable(mt->clk_peri_therm);
@@ -1099,6 +1102,10 @@ static int mtk_thermal_probe(struct platform_device *pdev)
clk_disable_unprepare(mt->clk_peri_therm);
err_disable_clk_auxadc:
clk_disable_unprepare(mt->clk_auxadc);
+err_umap_apmixed:
+ iounmap(apmixed_base);
+err_umap_auxadc:
+ iounmap(auxadc_base);
return ret;
}
--
2.17.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] thermal: mediatek: Fix some leaks in mtk_thermal_probe
2022-03-07 11:34 [PATCH] thermal: mediatek: Fix some leaks in mtk_thermal_probe Miaoqian Lin
@ 2022-03-08 5:36 ` Miles Chen
0 siblings, 0 replies; 2+ messages in thread
From: Miles Chen @ 2022-03-08 5:36 UTC (permalink / raw)
To: linmq006
Cc: amitk, daniel.lezcano, henry.yen, linux-arm-kernel, linux-kernel,
linux-mediatek, linux-pm, matthias.bgg, rafael, rui.zhang
Hi Miaoqian,
> If an error occurs after a successful 'of_iomap()' call, it must be undone
> by a corresponding 'iounmap()' call
>
> Fixes: 89945047b166 ("thermal: mediatek: Add tsensor support for V2 thermal system")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
>
Thanks for fixing this.
Reviewed-by: Miles Chen <miles.chen@mediatek.com>
Thanks,
Miles
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-08 5:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-07 11:34 [PATCH] thermal: mediatek: Fix some leaks in mtk_thermal_probe Miaoqian Lin
2022-03-08 5:36 ` Miles Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®