Skip to content

Commit

Permalink
kconfig: fix missing fclose() on error paths
Browse files Browse the repository at this point in the history
commit d23a0c3 upstream.

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 <ycaibb@gmail.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
masahir0y authored and gregkh committed Feb 16, 2022
1 parent 2142bc1 commit ebadf97
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions scripts/kconfig/confdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -977,10 +977,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");
Expand Down Expand Up @@ -1091,10 +1091,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");
Expand Down

0 comments on commit ebadf97

Please sign in to comment.