[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220214092517.204082731@linuxfoundation.org>
Date: Mon, 14 Feb 2022 10:27:25 +0100
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: linux-kernel@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
stable@...r.kernel.org, Ryan Cai <ycaibb@...il.com>,
Masahiro Yamada <masahiroy@...nel.org>
Subject: [PATCH 5.16 201/203] kconfig: fix missing fclose() on error paths
From: Masahiro Yamada <masahiroy@...nel.org>
commit d23a0c3718222a42430fd56359478a6fc7675070 upstream.
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@...il.com>
Signed-off-by: Masahiro Yamada <masahiroy@...nel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
---
scripts/kconfig/confdata.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -977,10 +977,10 @@ static int conf_write_autoconf_cmd(const
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");
@@ -1091,10 +1091,10 @@ static int __conf_write_autoconf(const c
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");
Powered by blists - more mailing lists