Skip to content

Commit d23a0c3

Browse files
committed
kconfig: fix missing fclose() on error paths
The file is not closed when ferror() fails. Fixes: 00d674c ("kconfig: refactor conf_write_dep()") Fixes: 57ddd07 ("kconfig: refactor conf_write_autoconf()") Reported-by: Ryan Cai <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 1cf5f15 commit d23a0c3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

scripts/kconfig/confdata.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -979,10 +979,10 @@ static int conf_write_autoconf_cmd(const char *autoconf_name)
979979

980980
fprintf(out, "\n$(deps_config): ;\n");
981981

982-
if (ferror(out)) /* error check for all fprintf() calls */
983-
return -1;
984-
982+
ret = ferror(out); /* error check for all fprintf() calls */
985983
fclose(out);
984+
if (ret)
985+
return -1;
986986

987987
if (rename(tmp, name)) {
988988
perror("rename");
@@ -1093,10 +1093,10 @@ static int __conf_write_autoconf(const char *filename,
10931093
print_symbol(file, sym);
10941094

10951095
/* check possible errors in conf_write_heading() and print_symbol() */
1096-
if (ferror(file))
1097-
return -1;
1098-
1096+
ret = ferror(file);
10991097
fclose(file);
1098+
if (ret)
1099+
return -1;
11001100

11011101
if (rename(tmp, filename)) {
11021102
perror("rename");

0 commit comments

Comments
 (0)