diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-06-19 15:41:54 +0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-06-29 12:57:35 +0400 |
commit | 18c67cb9f0d2ac1e5660899c852f657ba84ddd2e (patch) | |
tree | 5fe7824f32bc04b74d2b60924ed773da26e0f3ac /fs/splice.c | |
parent | 68d70d03f8f5bd10a0e7337210b13f536fd4aeb9 (diff) | |
download | kernel_goldelico_gta04-18c67cb9f0d2ac1e5660899c852f657ba84ddd2e.zip kernel_goldelico_gta04-18c67cb9f0d2ac1e5660899c852f657ba84ddd2e.tar.gz kernel_goldelico_gta04-18c67cb9f0d2ac1e5660899c852f657ba84ddd2e.tar.bz2 |
splice: lift checks from do_splice_from() into callers
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/splice.c')
-rw-r--r-- | fs/splice.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/fs/splice.c b/fs/splice.c index 78b3d12..cc53bd0 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -1098,17 +1098,6 @@ static long do_splice_from(struct pipe_inode_info *pipe, struct file *out, { ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int); - int ret; - - if (unlikely(!(out->f_mode & FMODE_WRITE))) - return -EBADF; - - if (unlikely(out->f_flags & O_APPEND)) - return -EINVAL; - - ret = rw_verify_area(WRITE, out, ppos, len); - if (unlikely(ret < 0)) - return ret; if (out->f_op && out->f_op->splice_write) splice_write = out->f_op->splice_write; @@ -1303,6 +1292,16 @@ long do_splice_direct(struct file *in, loff_t *ppos, struct file *out, }; long ret; + if (unlikely(!(out->f_mode & FMODE_WRITE))) + return -EBADF; + + if (unlikely(out->f_flags & O_APPEND)) + return -EINVAL; + + ret = rw_verify_area(WRITE, out, opos, len); + if (unlikely(ret < 0)) + return ret; + ret = splice_direct_to_actor(in, &sd, direct_splice_actor); if (ret > 0) *ppos = sd.pos; @@ -1358,6 +1357,16 @@ static long do_splice(struct file *in, loff_t __user *off_in, offset = out->f_pos; } + if (unlikely(!(out->f_mode & FMODE_WRITE))) + return -EBADF; + + if (unlikely(out->f_flags & O_APPEND)) + return -EINVAL; + + ret = rw_verify_area(WRITE, out, &offset, len); + if (unlikely(ret < 0)) + return ret; + file_start_write(out); ret = do_splice_from(ipipe, out, &offset, len, flags); file_end_write(out); |