mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: David Laight <David.Laight@aculab.com>
Cc: Linux Kbuild mailing list <linux-kbuild@vger.kernel.org>,
	Ryan Cai <ycaibb@gmail.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] kconfig: fix missing fclose() on error paths
Date: Sun, 13 Feb 2022 01:09:43 +0900	[thread overview]
Message-ID: <CAK7LNASK7O6aVfk57v5gsO2J6TPvdno6dqECme0+_NRj4si7LQ@mail.gmail.com> (raw)
In-Reply-To: <37efb2079f5443feaf4f0b10e15a57db@AcuMS.aculab.com>

On Fri, Feb 11, 2022 at 8:47 PM David Laight <David.Laight@aculab.com> wrote:
>
> 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@gmail.com>
> > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.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!)


Thanks for pointing it out. You are right.

I assume you are not opposed to this patch itself.

I will insert fflush() before ferror()
as a separate patch.





>         David
>
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)



-- 
Best Regards
Masahiro Yamada

      reply	other threads:[~2022-02-12 16:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-08  6:26 Masahiro Yamada
2022-02-10  0:53 ` Masahiro Yamada
2022-02-11 11:46   ` David Laight
2022-02-12 16:09     ` Masahiro Yamada [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAK7LNASK7O6aVfk57v5gsO2J6TPvdno6dqECme0+_NRj4si7LQ@mail.gmail.com \
    --to=masahiroy@kernel.org \
    --cc=David.Laight@aculab.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ycaibb@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®