[PATCH] ACPI: configfs: Fix potential table item leak on removal

From: Guangshuo Li

Date: Sat Nov 07 2026 - 01:56:22 EST


The table item type has no release callback, so dropping its last
configfs reference never frees the allocated struct acpi_table.

Add a release callback and only unload items that have a table.
Keep the AML buffer alive: ACPICA retains installed tables after
unload and requires the caller's buffer to remain valid for reload.

This issue was found by our static analysis tool under development.

Fixes: 612bd01fc6e0 ("ACPI: add support for loading SSDTs via configfs")
Signed-off-by: Guangshuo Li <liguangshuo@xxxxxxxxxxxxxxx>
---
Validation: Changed-object compilation passed with W=1 in the recorded
configuration. No hardware/kernel runtime test or full linked-kernel
build.
OpenAI Codex assisted with source review, patch implementation and
commit-message drafting. The submitter has reviewed the changes.

drivers/acpi/acpi_configfs.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/acpi_configfs.c b/drivers/acpi/acpi_configfs.c
index 6071699c7165..89ef17d5d5a5 100644
--- a/drivers/acpi/acpi_configfs.c
+++ b/drivers/acpi/acpi_configfs.c
@@ -199,8 +199,21 @@ static struct configfs_attribute *acpi_table_attrs[] = {
NULL,
};

+static void acpi_table_release(struct config_item *cfg)
+{
+ struct acpi_table *table = container_of(cfg, struct acpi_table, cfg);
+
+ /* ACPICA retains the table buffer for possible reload after unload. */
+ kfree(table);
+}
+
+static const struct configfs_item_operations acpi_table_item_ops = {
+ .release = acpi_table_release,
+};
+
static const struct config_item_type acpi_table_type = {
.ct_owner = THIS_MODULE,
+ .ct_item_ops = &acpi_table_item_ops,
.ct_bin_attrs = acpi_table_bin_attrs,
.ct_attrs = acpi_table_attrs,
};
@@ -224,7 +237,8 @@ static void acpi_table_drop_item(struct config_group *group,
struct acpi_table *table = container_of(cfg, struct acpi_table, cfg);

pr_debug("Host-directed Dynamic ACPI Table Unload\n");
- acpi_unload_table(table->index);
+ if (table->header)
+ acpi_unload_table(table->index);
config_item_put(cfg);
}


base-commit: 05441d697f7f9a927264f4058cbbc6a03dfcac9d