All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Matthew Wilcox <willy@infradead.org>
Cc: Chengguang Xu <cgxu519@mykernel.net>,
	viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] vfs: move fdput() to right place in ksys_sync_file_range()
Date: Wed, 11 May 2022 19:01:34 +0000	[thread overview]
Message-ID: <YnwIDpkIBem+MeeC@gmail.com> (raw)
In-Reply-To: <YnvbhmRUxPxWU2S3@casper.infradead.org>

On Wed, May 11, 2022 at 04:51:34PM +0100, Matthew Wilcox wrote:
> On Wed, May 11, 2022 at 11:45:03AM -0400, Chengguang Xu wrote:
> > Move fdput() to right place in ksys_sync_file_range() to
> > avoid fdput() after failed fdget().
> 
> Why?  fdput() is already conditional on FDPUT_FPUT so you're ...
> optimising the failure case?

"fdput() after failed fdget()" has confused people before, so IMO it's worth
cleaning this up.  But the commit message should make clear that it's a cleanup,
not a bug fix.  Also I recommend using an early return:

	f = fdget(fd);
	if (!f.file)
		return -EBADF;
	ret = sync_file_range(f.file, offset, nbytes, flags);
	fdput(f);
	return ret;

  reply	other threads:[~2022-05-11 19:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-11 15:45 [PATCH] vfs: move fdput() to right place in ksys_sync_file_range() Chengguang Xu
2022-05-11 15:51 ` Matthew Wilcox
2022-05-11 19:01   ` Eric Biggers [this message]
2022-05-11 21:43     ` Al Viro
2022-05-12  0:28       ` Al Viro
2022-05-12  0:42         ` Jens Axboe
2022-05-12  2:03       ` Alexei Starovoitov
2022-05-12 12:48         ` Brian Vazquez
2022-05-15  3:30       ` [BUG] double fget() in vhost/net (was Re: [PATCH] vfs: move fdput() to right place in ksys_sync_file_range()) Al Viro
2022-05-15 16:14         ` Michael S. Tsirkin
2022-05-16  4:17         ` Jason Wang
2022-05-16  7:54           ` Michael S. Tsirkin
2022-05-16  8:42             ` Jason Wang

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=YnwIDpkIBem+MeeC@gmail.com \
    --to=ebiggers@kernel.org \
    --cc=cgxu519@mykernel.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.