[PATCH 06/12] bootm: android: fix double close of fd

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Feb 16 00:42:22 PST 2026


On the success path, close(fd) is called before bootm_boot(), then
execution falls through to the err_close label which calls close(fd)
again.

Add an err_unlink label and jump past err_close on the success path
to avoid the double close.

Fixes: 8edffb6eef ("bootm: add generic android image handler")
Reported-by: GCC 14.2 -fanalyzer
Co-authored-by: Claude Opus 4.6 <noreply at anthropic.com>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 common/bootm-android-image.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/bootm-android-image.c b/common/bootm-android-image.c
index 828400fef772..6acc41c3dd66 100644
--- a/common/bootm-android-image.c
+++ b/common/bootm-android-image.c
@@ -128,9 +128,11 @@ static int do_bootm_aimage(struct image_data *img_data)
 
 	ret = bootm_boot(&bootm_data);
 
+	goto err_unlink;
+
 err_close:
 	close(fd);
-
+err_unlink:
 	if (kernel)
 		unlink(kernel);
 	if (initrd)
-- 
2.47.3




More information about the barebox mailing list