[PATCH] powerpc: Fix potential memory leak in icp_native_map_one_cpu()
Xiu Jianfeng
xiujianfeng at huawei.com
Sat Nov 19 17:45:56 AEDT 2022
Before return error, it has allocated memory by kasprintf() and save it
in @rname, may cause a memory leak issue, fix it.
Fixes: 0b05ac6e2480 ("powerpc/xics: Rewrite XICS driver")
Signed-off-by: Xiu Jianfeng <xiujianfeng at huawei.com>
---
arch/powerpc/sysdev/xics/icp-native.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/powerpc/sysdev/xics/icp-native.c b/arch/powerpc/sysdev/xics/icp-native.c
index edc17b6b1cc2..126230206350 100644
--- a/arch/powerpc/sysdev/xics/icp-native.c
+++ b/arch/powerpc/sysdev/xics/icp-native.c
@@ -239,6 +239,7 @@ static int __init icp_native_map_one_cpu(int hw_id, unsigned long addr,
if (!request_mem_region(addr, size, rname)) {
pr_warn("icp_native: Could not reserve ICP MMIO for CPU %d, interrupt server #0x%x\n",
cpu, hw_id);
+ kfree(rname);
return -EBUSY;
}
@@ -248,6 +249,7 @@ static int __init icp_native_map_one_cpu(int hw_id, unsigned long addr,
pr_warn("icp_native: Failed ioremap for CPU %d, interrupt server #0x%x, addr %#lx\n",
cpu, hw_id, addr);
release_mem_region(addr, size);
+ kfree(rname);
return -ENOMEM;
}
return 0;
--
2.17.1
More information about the Linuxppc-dev
mailing list