summaryrefslogtreecommitdiff
path: root/scripts/kconfig
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2022-02-08 09:26:18 +0300
committerMasahiro Yamada <masahiroy@kernel.org>2022-02-10 03:17:26 +0300
commitd23a0c3718222a42430fd56359478a6fc7675070 (patch)
tree8795d50d15a90ce4fb5712b6851c5dd9a020a98d /scripts/kconfig
parent1cf5f151d25fcca94689efd91afa0253621fb33a (diff)
downloadlinux-d23a0c3718222a42430fd56359478a6fc7675070.tar.xz
kconfig: fix missing fclose() on error paths
The file is not closed when ferror() fails. Fixes: 00d674cb3536 ("kconfig: refactor conf_write_dep()") Fixes: 57ddd07c4560 ("kconfig: refactor conf_write_autoconf()") Reported-by: Ryan Cai <ycaibb@gmail.com> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Diffstat (limited to 'scripts/kconfig')
-rw-r--r--scripts/kconfig/confdata.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 59717be31210..16897cb8cefd 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -979,10 +979,10 @@ static int conf_write_autoconf_cmd(const char *autoconf_name)
fprintf(out, "\n$(deps_config): ;\n");
- if (ferror(out)) /* error check for all fprintf() calls */
- return -1;
-
+ ret = ferror(out); /* error check for all fprintf() calls */
fclose(out);
+ if (ret)
+ return -1;
if (rename(tmp, name)) {
perror("rename");
@@ -1093,10 +1093,10 @@ static int __conf_write_autoconf(const char *filename,
print_symbol(file, sym);
/* check possible errors in conf_write_heading() and print_symbol() */
- if (ferror(file))
- return -1;
-
+ ret = ferror(file);
fclose(file);
+ if (ret)
+ return -1;
if (rename(tmp, filename)) {
perror("rename");