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>

Changed files
+6 -6
scripts
kconfig
+6 -6
scripts/kconfig/confdata.c
··· 979 979 980 980 fprintf(out, "\n$(deps_config): ;\n"); 981 981 982 - if (ferror(out)) /* error check for all fprintf() calls */ 983 - return -1; 984 - 982 + ret = ferror(out); /* error check for all fprintf() calls */ 985 983 fclose(out); 984 + if (ret) 985 + return -1; 986 986 987 987 if (rename(tmp, name)) { 988 988 perror("rename"); ··· 1093 1093 print_symbol(file, sym); 1094 1094 1095 1095 /* check possible errors in conf_write_heading() and print_symbol() */ 1096 - if (ferror(file)) 1097 - return -1; 1098 - 1096 + ret = ferror(file); 1099 1097 fclose(file); 1098 + if (ret) 1099 + return -1; 1100 1100 1101 1101 if (rename(tmp, filename)) { 1102 1102 perror("rename");