From: Miaoqian Lin <linmq006@gmail.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Amit Kucheria <amitk@kernel.org>, Zhang Rui <rui.zhang@intel.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
Henry Yen <henry.yen@mediatek.com>,
linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org
Cc: linmq006@gmail.com
Subject: [PATCH] thermal: mediatek: Fix some leaks in mtk_thermal_probe
Date: Mon, 7 Mar 2022 11:34:38 +0000 [thread overview]
Message-ID: <20220307113438.21338-1-linmq006@gmail.com> (raw)
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
next reply other threads:[~2022-03-07 11:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-07 11:34 Miaoqian Lin [this message]
2022-03-08 5:36 ` Miles Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220307113438.21338-1-linmq006@gmail.com \
--to=linmq006@gmail.com \
--cc=amitk@kernel.org \
--cc=daniel.lezcano@linaro.org \
--cc=henry.yen@mediatek.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®