9
0
Fork 0

imx-image: don't leak file handle

Signed-off-by: Lucas Stach <dev@lynxeye.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Lucas Stach 2014-04-21 22:15:24 +02:00 committed by Sascha Hauer
parent 9c63e92baa
commit 4d5ad7c9c6
1 changed files with 6 additions and 4 deletions

View File

@ -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)