]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
platform/x86/amd: Fix memory leak in wbrf_record()
authorZilin Guan <zilin@seu.edu.cn>
Tue, 6 Jan 2026 09:13:17 +0000 (09:13 +0000)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Thu, 15 Jan 2026 13:55:32 +0000 (15:55 +0200)
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>
drivers/platform/x86/amd/wbrf.c

index dd197b3aebe06a8638aa11ed24155b038a79a5b3..0f58d252b620afdb40a18aa46e1b189eb18c4f87 100644 (file)
@@ -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;