summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucas Stach <dev@lynxeye.de>2014-04-21 22:15:24 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-04-23 09:05:52 +0200
commit4d5ad7c9c64dd2e96e18cdf6ce5334f8f47de59c (patch)
tree7a13aca4b96e0d641f4ad8cc8a4106e1866dab5a
parent9c63e92baaea8fd35d9892e197a97d3bb39079f4 (diff)
downloadbarebox-4d5ad7c9c64dd2e96e18cdf6ce5334f8f47de59c.tar.gz
imx-image: don't leak file handle
Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--scripts/imx/imx-image.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c
index 1d935be..f4890c4 100644
--- a/scripts/imx/imx-image.c
+++ b/scripts/imx/imx-image.c
@@ -528,7 +528,7 @@ static int parse_config(const char *filename)
int lineno = 0;
char *line = NULL, *tmp;
char *argv[MAXARGS];
- int nargs, i, ret;
+ int nargs, i, ret = 0;
f = fopen(filename, "r");
if (!f) {
@@ -559,7 +559,7 @@ static int parse_config(const char *filename)
if (ret) {
fprintf(stderr, "error in line %d: %s\n",
lineno, strerror(-ret));
- return ret;
+ goto cleanup;
}
break;
}
@@ -567,11 +567,13 @@ static int parse_config(const char *filename)
if (ret == -ENOENT) {
fprintf(stderr, "no such command: %s\n", argv[0]);
- return ret;
+ goto cleanup;
}
}
- return 0;
+cleanup:
+ fclose(f);
+ return ret;
}
static int xread(int fd, void *buf, int len)