[PATCH] efi: payload: gracefully handle OOM in initrd allocation
Ahmad Fatoum
a.fatoum at pengutronix.de
Thu Aug 6 04:06:55 PDT 2026
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 at 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
More information about the barebox
mailing list