]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[linux] Free cached ACPI tables on shutdown
authorMichael Brown <mcb30@ipxe.org>
Tue, 2 Mar 2021 23:56:11 +0000 (23:56 +0000)
committerMichael Brown <mcb30@ipxe.org>
Tue, 2 Mar 2021 23:59:27 +0000 (23:59 +0000)
Free any cached ACPI tables for the sake of neatness (and a clean
report from Valgrind).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/interface/linux/linux_acpi.c

index 0f369bdaa890f664bd815532282e8fd38aac27fc..08833d61d373498da06f45f48370d309e026321a 100644 (file)
@@ -25,6 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #include <ipxe/linux_api.h>
 #include <ipxe/linux.h>
 #include <ipxe/list.h>
+#include <ipxe/init.h>
 #include <ipxe/acpi.h>
 
 /** ACPI sysfs directory */
@@ -170,4 +171,25 @@ static userptr_t linux_acpi_find ( uint32_t signature, unsigned int index ) {
        return UNULL;
 }
 
+/**
+ * Free cached ACPI data
+ *
+ */
+static void linux_acpi_shutdown ( int booting __unused ) {
+       struct linux_acpi_table *table;
+       struct linux_acpi_table *tmp;
+
+       list_for_each_entry_safe ( table, tmp, &linux_acpi_tables, list ) {
+               list_del ( &table->list );
+               free ( table->data );
+               free ( table );
+       }
+}
+
+/** ACPI shutdown function */
+struct startup_fn linux_acpi_startup_fn __startup_fn ( STARTUP_NORMAL ) = {
+       .name = "linux_acpi",
+       .shutdown = linux_acpi_shutdown,
+};
+
 PROVIDE_ACPI ( linux, acpi_find, linux_acpi_find );