Skip to content

Commit e3fdc89

Browse files
trondmyJ. Bruce Fields
authored andcommitted
nfsd: Fix error return values for nfsd4_clone_file_range()
If the parameter 'count' is non-zero, nfsd4_clone_file_range() will currently clobber all errors returned by vfs_clone_file_range() and replace them with EINVAL. Fixes: 42ec3d4 ("vfs: make remap_file_range functions take and...") Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Cc: stable@vger.kernel.org # v4.20+ Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent 8834f56 commit e3fdc89

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/nfsd/vfs.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,9 +557,11 @@ __be32 nfsd4_clone_file_range(struct file *src, u64 src_pos, struct file *dst,
557557
loff_t cloned;
558558

559559
cloned = vfs_clone_file_range(src, src_pos, dst, dst_pos, count, 0);
560+
if (cloned < 0)
561+
return nfserrno(cloned);
560562
if (count && cloned != count)
561-
cloned = -EINVAL;
562-
return nfserrno(cloned < 0 ? cloned : 0);
563+
return nfserrno(-EINVAL);
564+
return 0;
563565
}
564566

565567
ssize_t nfsd_copy_file_range(struct file *src, u64 src_pos, struct file *dst,

0 commit comments

Comments
 (0)