* [PATCH] efi: payload: gracefully handle OOM in initrd allocation
@ 2026-08-06 11:06 Ahmad Fatoum
2026-08-06 13:07 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2026-08-06 11:06 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] efi: payload: gracefully handle OOM in initrd allocation
2026-08-06 11:06 [PATCH] efi: payload: gracefully handle OOM in initrd allocation Ahmad Fatoum
@ 2026-08-06 13:07 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2026-08-06 13:07 UTC (permalink / raw)
To: barebox, Ahmad Fatoum
On Thu, 06 Aug 2026 13:06:55 +0200, Ahmad Fatoum wrote:
> An initrd can get quite big, so we should not assume that this an
> infallible allocation and instead propagate any OOM error code.
>
>
Applied, thanks!
[1/1] efi: payload: gracefully handle OOM in initrd allocation
https://git.pengutronix.de/cgit/barebox/commit/?id=4ca87477ca95 (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-06 13:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-06 11:06 [PATCH] efi: payload: gracefully handle OOM in initrd allocation Ahmad Fatoum
2026-08-06 13:07 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox