[LTP] [PATCH] acpi/ltp_acpi_cmds: Add kfree() and ACPI_FREE() to resolve memory leaks

Wang Kunfeng threefifteen.wangkunfeng@huawei.com
Thu Nov 25 07:47:00 CET 2021


1.In acpi_traverse_from_root() function,add kfree(dev_info) after using
acpi_get_object_info()
2.In acpi_test_resources() function,add  ACPI_FREE(buffer.pointer) after
using acpi_get_current_resources()
---
 testcases/kernel/device-drivers/acpi/ltp_acpi_cmds.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/testcases/kernel/device-drivers/acpi/ltp_acpi_cmds.c b/testcases/kernel/device-drivers/acpi/ltp_acpi_cmds.c
index 0ce70c6c1..d12dd6b94 100644
--- a/testcases/kernel/device-drivers/acpi/ltp_acpi_cmds.c
+++ b/testcases/kernel/device-drivers/acpi/ltp_acpi_cmds.c
@@ -221,6 +221,7 @@ static int acpi_traverse_from_root(void)
 		if (acpi_failure(status, "acpi_object_info failed"))
 			return 1;
 		prk_info("start from %4.4s", (char *)&dev_info->name);
+		kfree(dev_info);
 	} else {
 		/* continue with the last visited child */
 		parent = start_parent;
@@ -430,6 +431,7 @@ static int acpi_test_resources(void)
 	prk_alert("TEST -- acpi_get_current_resources");
 	status = acpi_get_current_resources(res_handle, &buffer);
 	err = acpi_failure(status, "failed get_current_resources");
+	ACPI_FREE(buffer.pointer);

 #ifdef ACPI_FUTURE_USAGE
 	prk_alert("TEST -- acpi_get_possible_resources");
--
2.17.1



More information about the ltp mailing list