Re: [PATCH] drivers: hwmon: fix ioremap and memremap leak

From: Guenter Roeck
Date: Sat Mar 18 2023 - 08:31:35 EST


On Sat, Mar 18, 2023 at 07:27:11PM +0800, Tianyi Jing wrote:
> 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, iounmap and memunmap is added to line: 754. And the
> declaration of 'version' is moved to xgene-hwmon.c:620 to help simplify
> getting 'version' below.
>
> Signed-off-by: Tianyi Jing <jingfelix@xxxxxxxxxxx>
> Reviewed-by: Dongliang Mu <dzm91@xxxxxxxxxxx>

Please just use devm_ioremap() and devm_memremap().

Thanks,
Guenter