[PATCH] ACPI: tables: handle failed initrd override mappings

Slavin Liu posted 1 patch 1 week, 4 days ago
drivers/acpi/tables.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] ACPI: tables: handle failed initrd override mappings
Posted by Slavin Liu 1 week, 4 days ago
The runtime AML table-loading path can invoke initrd override after
permanent mappings are enabled. Mapping bookkeeping can then fail.
Return AE_NO_MEMORY before reading the candidate header through NULL.

Detected by static analysis and reviewed with AI-assisted source auditing.

Fixes: b2a35003dfbc ("ACPI: Implement physical address table override")
Assisted-by: LLM
Signed-off-by: Slavin Liu <bolin.liu@seu.edu.cn>
---
 drivers/acpi/tables.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index eb93c060426f..749a128a889c 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -560,6 +560,8 @@ acpi_table_initrd_override(struct acpi_table_header *existing_table,
 	while (table_offset + ACPI_HEADER_SIZE <= all_tables_size) {
 		table = acpi_os_map_memory(acpi_tables_addr + table_offset,
 					   ACPI_HEADER_SIZE);
+		if (!table)
+			return AE_NO_MEMORY;
 		if (table_offset + table->length > all_tables_size) {
 			acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
 			WARN_ON(1);
Re: [PATCH] ACPI: tables: handle failed initrd override mappings
Posted by Rafael J. Wysocki (Intel) 1 week, 1 day ago
On Sun, Sep 13, 2026 at 2:51 PM Slavin Liu <bolin.liu@seu.edu.cn> wrote:
>
> The runtime AML table-loading path can invoke initrd override after
> permanent mappings are enabled. Mapping bookkeeping can then fail.
> Return AE_NO_MEMORY before reading the candidate header through NULL.
>
> Detected by static analysis and reviewed with AI-assisted source auditing.
>
> Fixes: b2a35003dfbc ("ACPI: Implement physical address table override")
> Assisted-by: LLM
> Signed-off-by: Slavin Liu <bolin.liu@seu.edu.cn>
> ---
>  drivers/acpi/tables.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
> index eb93c060426f..749a128a889c 100644
> --- a/drivers/acpi/tables.c
> +++ b/drivers/acpi/tables.c
> @@ -560,6 +560,8 @@ acpi_table_initrd_override(struct acpi_table_header *existing_table,
>         while (table_offset + ACPI_HEADER_SIZE <= all_tables_size) {
>                 table = acpi_os_map_memory(acpi_tables_addr + table_offset,
>                                            ACPI_HEADER_SIZE);
> +               if (!table)
> +                       return AE_NO_MEMORY;
>                 if (table_offset + table->length > all_tables_size) {
>                         acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
>                         WARN_ON(1);

Applied as 7.4 material, thanks!