Re: [PATCH] vfs: move fdput() to right place in ksys_sync_file_range()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux