diff mbox series

tools/mxsimage: Remove fclose on empty FILE pointer

Message ID 20211124072909.7540-1-hansson.mattias@gmail.com
State Superseded
Delegated to: Stefano Babic
Headers show
Series tools/mxsimage: Remove fclose on empty FILE pointer | expand

Commit Message

Mattias Hansson Nov. 24, 2021, 7:29 a.m. UTC
If `sb_load_cmdfile()` fails to open the configuration file it will jump
to error handling where the code will try to `fclose()` the FILE pointer
which is NULL causing `mkimage` to segfault.

This patch removes the `fclose()` since `fopen()` always returns NULL
instead of the file descriptor when failing.

Signed-off-by: Mattias Hansson <hansson.mattias@gmail.com>
---
 tools/mxsimage.c | 1 -
 1 file changed, 1 deletion(-)
diff mbox series

Patch

diff --git a/tools/mxsimage.c b/tools/mxsimage.c
index 002f4b525a..c7bd86ce52 100644
--- a/tools/mxsimage.c
+++ b/tools/mxsimage.c
@@ -1618,7 +1618,6 @@  static int sb_load_cmdfile(struct sb_image_ctx *ictx)
 	return 0;
 
 err_file:
-	fclose(fp);
 	fprintf(stderr, "ERR: Failed to load file \"%s\"\n",
 		ictx->cfg_filename);
 	return -EINVAL;