[PATCH 14/15] efi: payload: bootm: fix memory corruption on initrd load error
Ahmad Fatoum
a.fatoum at pengutronix.de
Tue Jan 27 00:39:24 PST 2026
initrd is a pointer to a pointer and its only used place the pointed at
pointer on stack. Freeing it will this trigger memory corruption.
Fix this by actually freeing the heap buffer.
Reported-by: Claude Sonnet v4.5 <noreply at anthropic.com>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
efi/payload/bootm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/efi/payload/bootm.c b/efi/payload/bootm.c
index 38bc8b23f215..f1f60e2eaa54 100644
--- a/efi/payload/bootm.c
+++ b/efi/payload/bootm.c
@@ -161,7 +161,7 @@ static int efi_load_ramdisk(struct image_data *data, void **initrd)
return 0;
free_mem:
- free(initrd);
+ free(initrd_mem);
return ret;
}
--
2.47.3
More information about the barebox
mailing list