Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 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@linux.intel.com>
Co-developed-by: Jianhao Xu <jianhao.xu@seu.edu.cn>
Signed-off-by: Jianhao Xu <jianhao.xu@seu.edu.cn>
Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
Link: https://patch.msgid.link/20260106091318.747019-1-zilin@seu.edu.cn
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

authored by

Zilin Guan and committed by
Ilpo Järvinen
2bf1877b 3113bcf4

+3 -1
+3 -1
drivers/platform/x86/amd/wbrf.c
··· 104 104 obj = acpi_evaluate_dsm(adev->handle, &wifi_acpi_dsm_guid, 105 105 WBRF_REVISION, WBRF_RECORD, &argv4); 106 106 107 - if (!obj) 107 + if (!obj) { 108 + kfree(tmp); 108 109 return -EINVAL; 110 + } 109 111 110 112 if (obj->type != ACPI_TYPE_INTEGER) { 111 113 ret = -EINVAL;