mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-09 15:29:16 +00:00
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>
This commit is contained in:
parent
1cf5f151d2
commit
d23a0c3718
@ -979,10 +979,10 @@ static int conf_write_autoconf_cmd(const char *autoconf_name)
|
|||||||
|
|
||||||
fprintf(out, "\n$(deps_config): ;\n");
|
fprintf(out, "\n$(deps_config): ;\n");
|
||||||
|
|
||||||
if (ferror(out)) /* error check for all fprintf() calls */
|
ret = ferror(out); /* error check for all fprintf() calls */
|
||||||
return -1;
|
|
||||||
|
|
||||||
fclose(out);
|
fclose(out);
|
||||||
|
if (ret)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (rename(tmp, name)) {
|
if (rename(tmp, name)) {
|
||||||
perror("rename");
|
perror("rename");
|
||||||
@ -1093,10 +1093,10 @@ static int __conf_write_autoconf(const char *filename,
|
|||||||
print_symbol(file, sym);
|
print_symbol(file, sym);
|
||||||
|
|
||||||
/* check possible errors in conf_write_heading() and print_symbol() */
|
/* check possible errors in conf_write_heading() and print_symbol() */
|
||||||
if (ferror(file))
|
ret = ferror(file);
|
||||||
return -1;
|
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
if (ret)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (rename(tmp, filename)) {
|
if (rename(tmp, filename)) {
|
||||||
perror("rename");
|
perror("rename");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user