mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] efi: payload: bootm: fix memory corruption on initrd load error
@ 2026-02-09 15:30 Ahmad Fatoum
  2026-02-10  9:02 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2026-02-09 15:30 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum, Claude Sonnet v4.5

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@anthropic.com>
Signed-off-by: Ahmad Fatoum <a.fatoum@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 ea5b1265aeaa..f4e6e6324bcd 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




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-02-10  9:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-09 15:30 [PATCH] efi: payload: bootm: fix memory corruption on initrd load error Ahmad Fatoum
2026-02-10  9:02 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox