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;