Skip to contentSkip to conversation

scripts/kwbimage: Fix resource leak in image_create()

PATCH Applied Alexander Shiyan 2 participants 3 messages Feb 3, 2014 – Feb 4, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 scripts/kwbimage: Fix resource leak in image_create()

---
 scripts/kwbimage.c | 1 +
 1 file changed, 1 insertion(+)
scripts/kwbimage.c +1 -0
index cd87456..c085d4d 100644
@@ -1343,6 +1343,7 @@ static int image_create(const char *input, const char *output,
 	rewind(fcfg);
 
 	ret = image_create_config_parse(fcfg, image_cfg, &cfgn);
+	fclose(fcfg);
 	if (ret) {
 		free(image_cfg);
 		return -1;
Signature · 7 lines
1.8.3.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 2/2 scripts/kwbimage: Fix resource leak in image_create_payload()

---
 scripts/kwbimage.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/kwbimage.c +2 -2
index c085d4d..f8abeb1 100644
@@ -701,18 +701,18 @@ static int image_create_payload(void *payload_start, size_t payloadsz,
 	if (ret < 0) {
 		fprintf(stderr, "Cannot stat payload file %s\n",
 			payload_filename);
+		fclose(payload);
 		return ret;
 	}
 
 	ret = fread(payload_start, s.st_size, 1, payload);
+	fclose(payload);
 	if (ret != 1) {
 		fprintf(stderr, "Cannot read payload file %s\n",
 			payload_filename);
 		return -1;
 	}
 
-	fclose(payload);
-
 	*payload_checksum = image_checksum32(payload_start, payloadsz);
 	return 0;
 }
Signature · 7 lines
1.8.3.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#2 lore raw
In reply to Alexander Shiyan
Quoted 1 line · Alexander Shiyan

Applied both, thanks

Sascha

Quoted 25 lines
---
 scripts/kwbimage.c | 1 +
 1 file changed, 1 insertion(+)
scripts/kwbimage.c +1 -0
index cd87456..c085d4d 100644
@@ -1343,6 +1343,7 @@ static int image_create(const char *input, const char *output,
 	rewind(fcfg);
 
 	ret = image_create_config_parse(fcfg, image_cfg, &cfgn);
+	fclose(fcfg);
 	if (ret) {
 		free(image_cfg);
 		return -1;
Signature · 7 lines
1.8.3.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox