[PATCH v3 1/2] platform/x86/amd: Fix memory leak in wbrf_record()

From: Zilin Guan

Date: Tue Jan 06 2026 - 04:16:31 EST


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 explicitly freeing the tmp buffer in the error handling
path of acpi_evaluate_dsm().

Fixes: 58e82a62669d ("platform/x86/amd: Add support for AMD ACPI based Wifi band RFI mitigation feature")
Suggested-by: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx>
Co-developed-by: Jianhao Xu <jianhao.xu@xxxxxxxxxx>
Signed-off-by: Jianhao Xu <jianhao.xu@xxxxxxxxxx>
Signed-off-by: Zilin Guan <zilin@xxxxxxxxxx>
---
Changes in v3:
- Split from v2 to separate the fix from the cleanup.

Changes in v2:
- Use scope-based cleanup helper __free() for automatic resource cleanup.

drivers/platform/x86/amd/wbrf.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/amd/wbrf.c b/drivers/platform/x86/amd/wbrf.c
index dd197b3aebe0..0f58d252b620 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)
+ if (!obj) {
+ kfree(tmp);
return -EINVAL;
+ }

if (obj->type != ACPI_TYPE_INTEGER) {
ret = -EINVAL;
--
2.34.1