Skip to contentSkip to conversation

tools: imx8image: Fix handle leak

PATCH In review Mikhail Ilin 3 participants 3 messages Nov 23, 2022 – Jan 31, 2023 Arm i.MX and Layerscape

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools: imx8image: Fix handle leak

The handle "fd" was created in imx8image.c:249 by calling the "fopen" function and is lost in imx8image.c:282.
Should close the 'fd' file descriptor before exiting the parse_cfg_file(image_t *param_stack, char *name) function.

Fixes a2b96ece5be1 ("tools: add i.MX8/8X image support")
---
 tools/imx8image.c | 1 +
 1 file changed, 1 insertion(+)
tools/imx8image.c +1 -0
index 01e1486911..395d5c64bd 100644
@@ -279,6 +279,7 @@ static uint32_t parse_cfg_file(image_t *param_stack, char *name)
 		}
 	}
 
+	fclose(fd);
 	return 0;
 }
 
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Mikhail Ilin

The handle "fd" was created in imx8image.c:249 by calling the "fopen" function and is lost in imx8image.c:282.
Should close the 'fd' file descriptor before exiting the parse_cfg_file(image_t *param_stack, char *name) function.

Quoted 6 lines
Fixes a2b96ece5be1 ("tools: add i.MX8/8X image support")
---
 tools/imx8image.c | 1 +
 1 file changed, 1 insertion(+)
#2 lore raw

PATCH 1/1 tools: imx8image: Fix handle leak

In reply to Mikhail Ilin
Quoted 7 lines

The handle "fd" was created in imx8image.c:249 by calling the "fopen"
function and is lost in imx8image.c:282.
Should close the 'fd' file descriptor before exiting the parse_cfg_file(image_t *param_stack, char *name) function.

Fixes a2b96ece5be1 ("tools: add i.MX8/8X image support")

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================