public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] tools/mxsimage: Remove fclose on empty FILE pointer
@ 2021-11-23  8:06 Mattias Hansson
  2021-11-23 19:12 ` Fabio Estevam
  2021-11-24  8:16 ` Wolfgang Denk
  0 siblings, 2 replies; 6+ messages in thread
From: Mattias Hansson @ 2021-11-23  8:06 UTC (permalink / raw)
  To: u-boot; +Cc: Mattias Hansson

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.
---
 tools/mxsimage.c | 1 -
 1 file changed, 1 deletion(-)

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;
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [PATCH] tools/mxsimage: Remove fclose on empty FILE pointer
@ 2021-11-24  7:29 Mattias Hansson
  0 siblings, 0 replies; 6+ messages in thread
From: Mattias Hansson @ 2021-11-24  7:29 UTC (permalink / raw)
  To: u-boot; +Cc: Mattias Hansson

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 --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;
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [PATCH] tools/mxsimage: Remove fclose on empty FILE pointer
@ 2021-11-19 15:44 Mattias Hansson
  0 siblings, 0 replies; 6+ messages in thread
From: Mattias Hansson @ 2021-11-19 15:44 UTC (permalink / raw)
  To: u-boot; +Cc: Mattias Hansson

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.
---
 tools/mxsimage.c | 1 -
 1 file changed, 1 deletion(-)

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;
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-11-24  8:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-23  8:06 [PATCH] tools/mxsimage: Remove fclose on empty FILE pointer Mattias Hansson
2021-11-23 19:12 ` Fabio Estevam
2021-11-24  8:16 ` Wolfgang Denk
2021-11-24  8:35   ` Mattias Hansson
  -- strict thread matches above, loose matches on Subject: below --
2021-11-24  7:29 Mattias Hansson
2021-11-19 15:44 Mattias Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox