firmware-utils/dgfirmare: fix possible resource leak
authorAndrea Dalla Costa <andrea@dallacosta.me>
Sat, 11 Jan 2020 21:27:39 +0000 (22:27 +0100)
committerJo-Philipp Wich <jo@mein.io>
Tue, 14 Jan 2020 16:48:50 +0000 (17:48 +0100)
Add missing calls to `fclose` in functions `write_img`, `write_rootfs`
and `write_kernel`.
The not-closed files could lead to resource leaks.

Signed-off-by: Andrea Dalla Costa <andrea@dallacosta.me>
tools/firmware-utils/src/dgfirmware.c

index e3257f1077903ed47c7be58f29d7ba0b5b6e754c..3ec4712ec9351328bcaf104ce0b6336f44a599bd 100644 (file)
@@ -86,6 +86,8 @@ void write_img(unsigned char* img, const char *fname)
     fclose(fp);
     exit(-1);
   }
+
+  fclose(fp);
 }
 
 
@@ -104,6 +106,8 @@ void write_rootfs(unsigned char* img, const char *fname)
     fclose(fp);
     exit(-1);
   }
+
+  fclose(fp);
 }
 
 
@@ -122,6 +126,8 @@ void write_kernel(unsigned char* img, const char *fname)
     fclose(fp);
     exit(-1);
   }
+
+  fclose(fp);
 }