All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Holmes-Mitra <dholmesm@google.com>
To: u-boot@lists.u-boot-project.org
Cc: Tom Rini <trini@konsulko.com>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	 Ilias Apalodimas <ilias.apalodimas@linaro.org>
Subject: [PATCH 1/4] qfw/acpi: Do not free non-heap addresses on linker error
Date: Thu, 03 Dec 2026 02:21:09 GMT	[thread overview]
Message-ID: <20261203022028.04-01-dholmesm@google.com> (raw)
In-Reply-To: <20261203022028.04-00-dholmesm@google.com>

On a BIOS linker error, write_acpi_tables() previously iterated every
fw_cfg file with a non-zero addr and passed it to free(). When
CONFIG_BLOBLIST_TABLES is enabled all file addresses lie inside the
bloblist, and without it ZONE_FSEG allocations lie in the caller's
table buffer rather than the heap; freeing them corrupts the allocator.
In addition, ctx->rsdp was left pointing at the invalidated RSDP.

Walk only the processed ALLOCATE entries, call free() solely for
ZONE_HIGH heap allocations when CONFIG_BLOBLIST_TABLES is disabled, and
clear ctx->rsdp on error.

Signed-off-by: Dan Holmes-Mitra <dholmesm@google.com>
---
 drivers/misc/qfw_acpi.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/misc/qfw_acpi.c b/drivers/misc/qfw_acpi.c
index afa3b82039..7cb81eb222 100644
--- a/drivers/misc/qfw_acpi.c
+++ b/drivers/misc/qfw_acpi.c
@@ -245,15 +245,23 @@ ulong write_acpi_tables(ulong addr)
 
 out:
 	if (ret) {
-		struct fw_cfg_file_iter iter;
-		for (file = qfw_file_iter_init(dev, &iter);
-		     !qfw_file_iter_end(&iter);
-		     file = qfw_file_iter_next(&iter)) {
-			if (file->addr) {
+		int j;
+
+		for (j = 0; j < i; j++) {
+			entry = table_loader + j;
+			if (le32_to_cpu(entry->command) !=
+			    BIOS_LINKER_LOADER_COMMAND_ALLOCATE)
+				continue;
+			file = qfw_find_file(dev, entry->alloc.file);
+			if (!file || !file->addr)
+				continue;
+			if (!IS_ENABLED(CONFIG_BLOBLIST_TABLES) &&
+			    entry->alloc.zone ==
+			    BIOS_LINKER_LOADER_ALLOC_ZONE_HIGH)
 				free((void *)file->addr);
-				file->addr = 0;
-			}
+			file->addr = 0;
 		}
+		ctx->rsdp = NULL;
 	}
 
 	free(table_loader);
-- 
2.56.1.911.g883d8bcb20-goog


  reply	other threads:[~2026-12-03  5:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  2:21 [PATCH 0/4] qfw/acpi & efi_loader: Fix linker cleanup, RSDP bounds, and absent/offset ACPI handling Dan Holmes-Mitra
2026-12-03  2:21 ` Dan Holmes-Mitra [this message]
2026-12-03  2:21 ` [PATCH 2/4] qfw/acpi: Guard ACPI 1.0 RSDP bounds and NULL lookup Dan Holmes-Mitra
2026-12-03  2:21 ` [PATCH 3/4] qfw/acpi: Skip absent ACPI bloblist and size from table-loader Dan Holmes-Mitra
2026-12-03  2:21 ` [PATCH 4/4] efi_loader: Handle offset or absent runtime ACPI tables Dan Holmes-Mitra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261203022028.04-01-dholmesm@google.com \
    --to=dholmesm@google.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.u-boot-project.org \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.