From a582cd7f651c2030637d4b5896ed383424b3425a Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Apr 20 2023 11:00:46 +0000 Subject: hwmon: (xgene) Fix ioremap and memremap leak (bsc#1012628). --- diff --git a/patches.kernel.org/6.2.12-090-hwmon-xgene-Fix-ioremap-and-memremap-leak.patch b/patches.kernel.org/6.2.12-090-hwmon-xgene-Fix-ioremap-and-memremap-leak.patch new file mode 100644 index 0000000..d1d49cc --- /dev/null +++ b/patches.kernel.org/6.2.12-090-hwmon-xgene-Fix-ioremap-and-memremap-leak.patch @@ -0,0 +1,60 @@ +From: Tianyi Jing +Date: Sat, 18 Mar 2023 22:38:51 +0800 +Subject: [PATCH] hwmon: (xgene) Fix ioremap and memremap leak +References: bsc#1012628 +Patch-mainline: 6.2.12 +Git-commit: 813cc94c7847ae4a17e9f744fb4dbdf7df6bd732 + +[ Upstream commit 813cc94c7847ae4a17e9f744fb4dbdf7df6bd732 ] + +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 +Reviewed-by: Dongliang Mu +Link: https://lore.kernel.org/r/20230318143851.2191625-1-jingfelix@hust.edu.cn +[groeck: Fixed formatting and subject] +Signed-off-by: Guenter Roeck +Signed-off-by: Sasha Levin +Signed-off-by: Jiri Slaby +--- + drivers/hwmon/xgene-hwmon.c | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/drivers/hwmon/xgene-hwmon.c b/drivers/hwmon/xgene-hwmon.c +index d1abea49..78d9f52e 100644 +--- a/drivers/hwmon/xgene-hwmon.c ++++ b/drivers/hwmon/xgene-hwmon.c +@@ -698,14 +698,14 @@ 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->comm_base_addr, +- pcc_chan->shmem_size); ++ 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->comm_base_addr, +- pcc_chan->shmem_size, +- MEMREMAP_WB); ++ ctx->pcc_comm_addr = devm_memremap(&pdev->dev, ++ ctx->comm_base_addr, ++ pcc_chan->shmem_size, ++ MEMREMAP_WB); + } else { + dev_err(&pdev->dev, "Failed to get PCC comm region\n"); + rc = -ENODEV; +-- +2.35.3 + diff --git a/series.conf b/series.conf index 2b25de9..35c0ef3 100644 --- a/series.conf +++ b/series.conf @@ -2317,6 +2317,7 @@ patches.kernel.org/6.2.12-087-ACPI-video-Add-backlight-native-DMI-quirk-for-.patch patches.kernel.org/6.2.12-088-drm-panel-orientation-quirks-Add-quirk-for-Len.patch patches.kernel.org/6.2.12-089-hwmon-peci-cputemp-Fix-miscalculated-DTS-for-S.patch + patches.kernel.org/6.2.12-090-hwmon-xgene-Fix-ioremap-and-memremap-leak.patch ######################################################## # Build fixes that apply to the vanilla kernel too.