From: "J. Bruce Fields" <bfields@fieldses.org>
To: Masatake YAMATO <yamato@redhat.com>
Cc: linux-nfs@vger.kernel.org, steved@redhat.com
Subject: Re: [PATCH v3] closing fd associated with /proc/fs/nfsd/export_features
Date: Tue, 12 Jul 2011 10:20:19 -0400 [thread overview]
Message-ID: <20110712142019.GE2162@fieldses.org> (raw)
In-Reply-To: <20110712.220109.419121694701200961.yamato@redhat.com>
On Tue, Jul 12, 2011 at 10:01:09PM +0900, Masatake YAMATO wrote:
> Very sorry for posting again and again.
Whoops, shows how carefully I was reviewing....
> fd shuold be closed even if read is failed.
Looks good to me.
--b.
>
> Signed-off-by: Masatake YAMATO <yamato@redhat.com>
>
> diff --git a/support/nfs/exports.c b/support/nfs/exports.c
> index c250383..c96500f 100644
> --- a/support/nfs/exports.c
> +++ b/support/nfs/exports.c
> @@ -784,8 +784,9 @@ struct export_features *get_export_features(void)
> fd = open(path, O_RDONLY);
> if (fd == -1)
> goto good;
> - fd = read(fd, buf, 50);
> - if (fd == -1)
> + c = read(fd, buf, 50);
> + close(fd);
> + if (c == -1)
> goto err;
> c = sscanf(buf, "%x %x", &ef.flags, &ef.secinfo_flags);
> if (c != 2)
>
> > Sorry, my patch has a serious bug.
> > The value returned from read() is stored to fd.
> > So fd should not be passed to close().
> >
> > I rearranged the code as below.
> >
> > Signed-off-by: Masatake YAMATO <yamato@redhat.com>
> >
> > diff --git a/support/nfs/exports.c b/support/nfs/exports.c
> > index c250383..744c01b 100644
> > --- a/support/nfs/exports.c
> > +++ b/support/nfs/exports.c
> > @@ -784,9 +784,10 @@ struct export_features *get_export_features(void)
> > fd = open(path, O_RDONLY);
> > if (fd == -1)
> > goto good;
> > - fd = read(fd, buf, 50);
> > - if (fd == -1)
> > + c = read(fd, buf, 50);
> > + if (c == -1)
> > goto err;
> > + close(fd);
> > c = sscanf(buf, "%x %x", &ef.flags, &ef.secinfo_flags);
> > if (c != 2)
> > goto err;
> >
> >
> >> On Tue, Jul 12, 2011 at 11:47:00AM +0900, Masatake YAMATO wrote:
> >>> A fd associated with /proc/fs/nfsd/export_features opened in get_export_features is
> >>> not closed.
> >>>
> >>>
> >>> Signed-off-by: Masatake YAMATO <yamato@redhat.com>
> >> Acked-by: J. Bruce Fields <bfields@redhat.com>
> >>>
> >>> diff --git a/support/nfs/exports.c b/support/nfs/exports.c
> >>> index c250383..819a18a 100644
> >>> --- a/support/nfs/exports.c
> >>> +++ b/support/nfs/exports.c
> >>> @@ -787,6 +787,7 @@ struct export_features *get_export_features(void)
> >>> fd = read(fd, buf, 50);
> >>> if (fd == -1)
> >>> goto err;
> >>> + close(fd);
> >>> c = sscanf(buf, "%x %x", &ef.flags, &ef.secinfo_flags);
> >>> if (c != 2)
> >>> goto err;
> >>> --
> >>> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> >>> the body of a message to majordomo@vger.kernel.org
> >>> More majordomo info at http://vger.kernel.org/majordomo-info.html
> >> --
> >> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> >> the body of a message to majordomo@vger.kernel.org
> >> More majordomo info at http://vger.kernel.org/majordomo-info.html
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2011-07-12 14:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-12 2:47 [PATCH] closing fd associated with /proc/fs/nfsd/export_features Masatake YAMATO
2011-07-12 10:46 ` J. Bruce Fields
2011-07-12 12:38 ` [PATCH v2] " Masatake YAMATO
2011-07-12 13:01 ` [PATCH v3] " Masatake YAMATO
2011-07-12 14:03 ` Steve Dickson
2011-07-12 14:20 ` J. Bruce Fields [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=20110712142019.GE2162@fieldses.org \
--to=bfields@fieldses.org \
--cc=linux-nfs@vger.kernel.org \
--cc=steved@redhat.com \
--cc=yamato@redhat.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;
as well as URLs for NNTP newsgroup(s).