mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3 1/2] platform/x86/amd: Fix memory leak in wbrf_record()
@ 2026-01-06  9:13 Zilin Guan
  2026-01-06  9:13 ` [PATCH v3 2/2] platform/x86/amd: Use scope-based cleanup for wbrf_record() Zilin Guan
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Zilin Guan @ 2026-01-06  9:13 UTC (permalink / raw)
  To: hansg
  Cc: ilpo.jarvinen, platform-driver-x86, linux-kernel, Zilin Guan, Jianhao Xu

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>
---
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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-01-26 14:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-06  9:13 [PATCH v3 1/2] platform/x86/amd: Fix memory leak in wbrf_record() Zilin Guan
2026-01-06  9:13 ` [PATCH v3 2/2] platform/x86/amd: Use scope-based cleanup for wbrf_record() Zilin Guan
2026-01-06 11:00 ` [PATCH v3 1/2] platform/x86/amd: Fix memory leak in wbrf_record() Markus Elfring
2026-01-15 14:27 ` Ilpo Järvinen
2026-01-26 14:30 ` Ilpo Järvinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®