[PATCH v2 28/42] ACPICA: tables: Fix table buffer leak when Load fails verification
From: Maciej Wieczor-Retman
Date: Fri Nov 20 2026 - 12:23:24 EST
From: Pawel Chmielewski <pawel.chmielewski@xxxxxxxxxxxxxxx>
Commit "Improve error handling in table loading process to ensure proper
cleanup on failure" removed the ACPI_FREE of the table buffer from the
error path of AcpiExLoadOp, assuming lower layers always release it.
That holds only when the table was installed and AcpiTbLoadTable failed.
If AcpiTbVerifyTempTable fails in AcpiTbInstallStandardTable (e.g.
AE_ALREADY_EXISTS when the table is already loaded), the error path
calls AcpiTbReleaseTempTable, which is a no-op for
ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL. The buffer allocated by the Load
operator leaks on every failed Load.
Make AcpiTbInstallAndLoadTable always consume an INTERNAL_VIRTUAL
table and free it when AcpiTbInstallStandardTable fails. Document
this in the function header and fix the comment in AcpiExLoadOp.
Verified with acpiexec by executing Load twice on the same SSDT buffer.
Link: https://github.com/acpica/acpica/commit/bc6a09d20be6
Signed-off-by: Pawel Chmielewski <pawel.chmielewski@xxxxxxxxxxxxxxx>
Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@xxxxxxxxx>
---
drivers/acpi/acpica/exconfig.c | 8 ++------
drivers/acpi/acpica/tbdata.c | 12 +++++++++++-
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/drivers/acpi/acpica/exconfig.c b/drivers/acpi/acpica/exconfig.c
index cb2eed531c67..2354755ce8b3 100644
--- a/drivers/acpi/acpica/exconfig.c
+++ b/drivers/acpi/acpica/exconfig.c
@@ -461,12 +461,8 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
acpi_ex_enter_interpreter();
if (ACPI_FAILURE(status)) {
- /*
- * Table buffer is already freed by acpi_tb_uninstall_table
- * in acpi_tb_install_and_load_table if installation succeeded,
- * or by acpi_tb_uninstall_table in acpi_tb_install_standard_table
- * if verification failed after partial setup.
- */
+ /* Table buffer is already freed by acpi_tb_install_and_load_table */
+
return_ACPI_STATUS(status);
}
diff --git a/drivers/acpi/acpica/tbdata.c b/drivers/acpi/acpica/tbdata.c
index 8185c6f7ce23..c756d34eeb44 100644
--- a/drivers/acpi/acpica/tbdata.c
+++ b/drivers/acpi/acpica/tbdata.c
@@ -995,7 +995,9 @@ acpi_tb_load_table(u32 table_index, struct acpi_namespace_node *parent_node)
*
* RETURN: Status
*
- * DESCRIPTION: Install and load an ACPI table
+ * DESCRIPTION: Install and load an ACPI table. An internally allocated
+ * table (ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL) is always consumed,
+ * on failure it is freed here.
*
******************************************************************************/
@@ -1015,6 +1017,14 @@ acpi_tb_install_and_load_table(acpi_physical_address address,
status = acpi_tb_install_standard_table(address, flags, table, TRUE,
override, &i);
if (ACPI_FAILURE(status)) {
+ /*
+ * Table was not installed (e.g. it is a duplicate or failed
+ * verification), so nobody else will free an internal buffer
+ */
+ if ((flags & ACPI_TABLE_ORIGIN_MASK) ==
+ ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL) {
+ ACPI_FREE(table);
+ }
goto exit;
}
--
2.56.0