Skip to content

Commit 813cc94

Browse files
jingfelixgroeck
authored andcommitted
hwmon: (xgene) Fix ioremap and memremap leak
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> Link: https://lore.kernel.org/r/20230318143851.2191625-1-jingfelix@hust.edu.cn [groeck: Fixed formatting and subject] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent 2315332 commit 813cc94

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/hwmon/xgene-hwmon.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -698,14 +698,14 @@ static int xgene_hwmon_probe(struct platform_device *pdev)
698698
ctx->comm_base_addr = pcc_chan->shmem_base_addr;
699699
if (ctx->comm_base_addr) {
700700
if (version == XGENE_HWMON_V2)
701-
ctx->pcc_comm_addr = (void __force *)ioremap(
702-
ctx->comm_base_addr,
703-
pcc_chan->shmem_size);
701+
ctx->pcc_comm_addr = (void __force *)devm_ioremap(&pdev->dev,
702+
ctx->comm_base_addr,
703+
pcc_chan->shmem_size);
704704
else
705-
ctx->pcc_comm_addr = memremap(
706-
ctx->comm_base_addr,
707-
pcc_chan->shmem_size,
708-
MEMREMAP_WB);
705+
ctx->pcc_comm_addr = devm_memremap(&pdev->dev,
706+
ctx->comm_base_addr,
707+
pcc_chan->shmem_size,
708+
MEMREMAP_WB);
709709
} else {
710710
dev_err(&pdev->dev, "Failed to get PCC comm region\n");
711711
rc = -ENODEV;

0 commit comments

Comments
 (0)