mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] efi: payload: gracefully handle OOM in initrd allocation
Date: Thu,  6 Aug 2026 13:06:55 +0200	[thread overview]
Message-ID: <20260806110658.3761972-1-a.fatoum@pengutronix.de> (raw)

An initrd can get quite big, so we should not assume that this an
infallible allocation and instead propagate any OOM error code.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 efi/payload/handover.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/efi/payload/handover.c b/efi/payload/handover.c
index bef726ae303c..544fdfb3c6ad 100644
--- a/efi/payload/handover.c
+++ b/efi/payload/handover.c
@@ -146,7 +146,13 @@ static int do_bootm_efi(struct image_data *data)
 			ret = -errno;
 			goto err_free;
 		}
-		initrd = xmemalign(PAGE_SIZE, PAGE_ALIGN(size));
+		initrd = memalign(PAGE_SIZE, PAGE_ALIGN(size));
+		if (!initrd) {
+			free(tmp);
+			ret = -ENOMEM;
+			goto err_free;
+		}
+
 		memcpy(initrd, tmp, size);
 		memset(initrd + size, 0, PAGE_ALIGN(size) - size);
 		free(tmp);
-- 
2.47.3




             reply	other threads:[~2026-08-06 11:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-06 11:06 Ahmad Fatoum [this message]
2026-08-06 13:07 ` Sascha Hauer

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=20260806110658.3761972-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox