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

Alexander Shiyan shc_work at mail.ru
Mon Feb 3 13:50:50 EST 2014


Signed-off-by: Alexander Shiyan <shc_work at mail.ru>
---
 scripts/kwbimage.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/kwbimage.c b/scripts/kwbimage.c
index c085d4d..f8abeb1 100644
--- a/scripts/kwbimage.c
+++ b/scripts/kwbimage.c
@@ -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;
 }
-- 
1.8.3.2




More information about the barebox mailing list