[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251230064325.1036637-1-zilin@seu.edu.cn>
Date: Tue, 30 Dec 2025 06:43:25 +0000
From: Zilin Guan <zilin@....edu.cn>
To: hansg@...nel.org
Cc: ilpo.jarvinen@...ux.intel.com,
platform-driver-x86@...r.kernel.org,
linux-kernel@...r.kernel.org,
Zilin Guan <zilin@....edu.cn>,
Jianhao Xu <jianhao.xu@....edu.cn>
Subject: [PATCH] platform/x86/amd: Fix memory leak in wbrf_record()
The tmp buffer is allocated using kcalloc() but is not freed if
acpi_evaluate_dsm() fails. This causes a memory leak in the error path.
Fix this by adding a free_tmp label and jumping to it when obj is NULL,
ensuring tmp is properly freed.
Fixes: 58e82a62669d ("platform/x86/amd: Add support for AMD ACPI based Wifi band RFI mitigation feature")
Co-developed-by: Jianhao Xu <jianhao.xu@....edu.cn>
Signed-off-by: Jianhao Xu <jianhao.xu@....edu.cn>
Signed-off-by: Zilin Guan <zilin@....edu.cn>
---
drivers/platform/x86/amd/wbrf.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/x86/amd/wbrf.c b/drivers/platform/x86/amd/wbrf.c
index dd197b3aebe0..b35e9369b62a 100644
--- a/drivers/platform/x86/amd/wbrf.c
+++ b/drivers/platform/x86/amd/wbrf.c
@@ -104,8 +104,10 @@ static int wbrf_record(struct acpi_device *adev, uint8_t action, struct wbrf_ran
obj = acpi_evaluate_dsm(adev->handle, &wifi_acpi_dsm_guid,
WBRF_REVISION, WBRF_RECORD, &argv4);
- if (!obj)
- return -EINVAL;
+ if (!obj) {
+ ret = -EINVAL;
+ goto free_tmp;
+ }
if (obj->type != ACPI_TYPE_INTEGER) {
ret = -EINVAL;
@@ -118,6 +120,7 @@ static int wbrf_record(struct acpi_device *adev, uint8_t action, struct wbrf_ran
out:
ACPI_FREE(obj);
+free_tmp:
kfree(tmp);
return ret;
--
2.34.1
Powered by blists - more mailing lists