author: Amir Goldstein <amir73il@gmail.com> 2016-10-26 22:34:01 +0300
committer: Miklos Szeredi <mszeredi@redhat.com> 2016-12-16 11:02:54 +0100
commit: b335e9d9944d9c66cdaadc5e295cc845c31e40a0
parent: 031a072a0b8ac2646def77aa310a95016c884bb0
Commit Summary:
Diffstat:
1 file changed, 5 insertions, 5 deletions
diff --git a/fs/read_write.c b/fs/read_write.c
index c4e206b875d0..53bccd1c786e 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1655,6 +1655,11 @@ int vfs_clone_file_range(struct file *file_in, loff_t pos_in,
struct inode *inode_out = file_inode(file_out);
int ret;
+ if (S_ISDIR(inode_in->i_mode) || S_ISDIR(inode_out->i_mode))
+ return -EISDIR;
+ if (!S_ISREG(inode_in->i_mode) || !S_ISREG(inode_out->i_mode))
+ return -EINVAL;
+
/*
* FICLONE/FICLONERANGE ioctls enforce that src and dest files are on
* the same mount. Practically, they only need to be on the same file
@@ -1663,11 +1668,6 @@ int vfs_clone_file_range(struct file *file_in, loff_t pos_in,
if (inode_in->i_sb != inode_out->i_sb)
return -EXDEV;
- if (S_ISDIR(inode_in->i_mode) || S_ISDIR(inode_out->i_mode))
- return -EISDIR;
- if (!S_ISREG(inode_in->i_mode) || !S_ISREG(inode_out->i_mode))
- return -EINVAL;
-
if (!(file_in->f_mode & FMODE_READ) ||
!(file_out->f_mode & FMODE_WRITE) ||
(file_out->f_flags & O_APPEND))