Skip to content

Commit

Permalink
ocfs2: add missing errno in ocfs2_ioctl_move_extents()
Browse files Browse the repository at this point in the history
If the file is not regular or writeable, it should return errno(EPERM).

This patch is based on 85a258b ("ocfs2: fix error handling in
ocfs2_ioctl_move_extents()").

Signed-off-by: Younger Liu <[email protected]>
Signed-off-by: Jie Liu <[email protected]>
Reviewed-by: Dan Carpenter <[email protected]>
Reviewed-by: Jie Liu <[email protected]>
Cc: Joel Becker <[email protected]>
Cc: Mark Fasheh <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Younger Liu authored and torvalds committed Nov 13, 2013
1 parent 8abaae8 commit bfbca92
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions fs/ocfs2/move_extents.c
Original file line number Diff line number Diff line change
Expand Up @@ -1066,8 +1066,10 @@ int ocfs2_ioctl_move_extents(struct file *filp, void __user *argp)
if (status)
return status;

if ((!S_ISREG(inode->i_mode)) || !(filp->f_mode & FMODE_WRITE))
if ((!S_ISREG(inode->i_mode)) || !(filp->f_mode & FMODE_WRITE)) {
status = -EPERM;
goto out_drop;
}

if (inode->i_flags & (S_IMMUTABLE|S_APPEND)) {
status = -EPERM;
Expand All @@ -1089,8 +1091,10 @@ int ocfs2_ioctl_move_extents(struct file *filp, void __user *argp)
goto out_free;
}

if (range.me_start > i_size_read(inode))
if (range.me_start > i_size_read(inode)) {
status = -EINVAL;
goto out_free;
}

if (range.me_start + range.me_len > i_size_read(inode))
range.me_len = i_size_read(inode) - range.me_start;
Expand Down

0 comments on commit bfbca92

Please sign in to comment.