[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <37efb2079f5443feaf4f0b10e15a57db@AcuMS.aculab.com>
Date: Fri, 11 Feb 2022 11:46:59 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Masahiro Yamada' <masahiroy@...nel.org>,
Linux Kbuild mailing list <linux-kbuild@...r.kernel.org>
CC: Ryan Cai <ycaibb@...il.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] kconfig: fix missing fclose() on error paths
From: Masahiro Yamada
> Sent: 10 February 2022 00:54
> >
> > 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>
> > ---
>
>
> Applied to linux-kbuild/fixes.
>
>
> >
> > scripts/kconfig/confdata.c | 12 ++++++------
> > 1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
> > index 59717be31210..16897cb8cefd 100644
> > --- a/scripts/kconfig/confdata.c
> > +++ b/scripts/kconfig/confdata.c
> > @@ -979,10 +979,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;
There's not much point calling ferror() unless you call fflush() first.
Similarly there's about zero point in checking the return from fprintf().
At least I've never found any distro adding 'must_check' to fprintf().
('must_not_check' would be more appropriate!)
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists