From: Tianyi Jing <jingfelix@hust.edu.cn>
To: Jean Delvare <jdelvare@suse.com>, Guenter Roeck <linux@roeck-us.net>
Cc: Tianyi Jing <jingfelix@hust.edu.cn>,
Dongliang Mu <dzm91@hust.edu.cn>,
linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2] drivers: hwmon: fix ioremap and memremap leak
Date: Sat, 18 Mar 2023 22:38:51 +0800 [thread overview]
Message-ID: <20230318143851.2191625-1-jingfelix@hust.edu.cn> (raw)
Smatch reports:
drivers/hwmon/xgene-hwmon.c:757 xgene_hwmon_probe() warn:
'ctx->pcc_comm_addr' from ioremap() not released on line: 757.
This is because in drivers/hwmon/xgene-hwmon.c:701 xgene_hwmon_probe(),
ioremap and memremap is not released, which may cause a leak.
To fix this, ioremap and memremap is modified to devm_ioremap and
devm_memremap.
Signed-off-by: Tianyi Jing <jingfelix@hust.edu.cn>
Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
---
v1 -> v2: use devm_ioremap and devm_memremap instead.
drivers/hwmon/xgene-hwmon.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/xgene-hwmon.c b/drivers/hwmon/xgene-hwmon.c
index 5cde837bfd09..a25fae9b19b7 100644
--- a/drivers/hwmon/xgene-hwmon.c
+++ b/drivers/hwmon/xgene-hwmon.c
@@ -698,11 +698,13 @@ static int xgene_hwmon_probe(struct platform_device *pdev)
ctx->comm_base_addr = pcc_chan->shmem_base_addr;
if (ctx->comm_base_addr) {
if (version == XGENE_HWMON_V2)
- ctx->pcc_comm_addr = (void __force *)ioremap(
+ ctx->pcc_comm_addr = (void __force *)devm_ioremap(
+ &pdev->dev,
ctx->comm_base_addr,
pcc_chan->shmem_size);
else
- ctx->pcc_comm_addr = memremap(
+ ctx->pcc_comm_addr = devm_memremap(
+ &pdev->dev,
ctx->comm_base_addr,
pcc_chan->shmem_size,
MEMREMAP_WB);
--
2.34.1
next reply other threads:[~2023-03-18 14:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-18 14:38 Tianyi Jing [this message]
2023-03-21 14:52 ` [PATCH v2] drivers: hwmon: fix ioremap and memremap leak Guenter Roeck
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=20230318143851.2191625-1-jingfelix@hust.edu.cn \
--to=jingfelix@hust.edu.cn \
--cc=dzm91@hust.edu.cn \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
/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;
as well as URLs for NNTP newsgroup(s).