[PATCH] ACPI / utils: Fix memory leak on an error return path in acpi_evaluate_reference()

From: Xiongfeng Wang
Date: Thu Nov 09 2017 - 01:31:05 EST


When package.count is larger than ACPI_MAS_HANDLES, buffer.pointer is
not freed before the function returns AE_NO_MEMORY. Fix this possible
memory leak by kfree'ing it.

Signed-off-by: Xiongfeng Wang <wangxiongfeng2@xxxxxxxxxx>
---
drivers/acpi/utils.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index b9d956c..9282549 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -355,6 +355,7 @@
}

if (package->package.count > ACPI_MAX_HANDLES) {
+ kfree(package);
return AE_NO_MEMORY;
}
list->count = package->package.count;
--
1.7.12.4