diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-06-19 07:41:54 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-06-29 04:57:35 -0400 |
commit | 18c67cb9f0d2ac1e5660899c852f657ba84ddd2e (patch) | |
tree | 5fe7824f32bc04b74d2b60924ed773da26e0f3ac /fs | |
parent | 68d70d03f8f5bd10a0e7337210b13f536fd4aeb9 (diff) |
splice: lift checks from do_splice_from() into callers
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-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 78b3d12046e7..cc53bd04be8f 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, | |||
1098 | { | 1098 | { |
1099 | ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, | 1099 | ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, |
1100 | loff_t *, size_t, unsigned int); | 1100 | loff_t *, size_t, unsigned int); |
1101 | int ret; | ||
1102 | |||
1103 | if (unlikely(!(out->f_mode & FMODE_WRITE))) | ||
1104 | return -EBADF; | ||
1105 | |||
1106 | if (unlikely(out->f_flags & O_APPEND)) | ||
1107 | return -EINVAL; | ||
1108 | |||
1109 | ret = rw_verify_area(WRITE, out, ppos, len); | ||
1110 | if (unlikely(ret < 0)) | ||
1111 | return ret; | ||
1112 | 1101 | ||
1113 | if (out->f_op && out->f_op->splice_write) | 1102 | if (out->f_op && out->f_op->splice_write) |
1114 | splice_write = out->f_op->splice_write; | 1103 | splice_write = out->f_op->splice_write; |
@@ -1303,6 +1292,16 @@ long do_splice_direct(struct file *in, loff_t *ppos, struct file *out, | |||
1303 | }; | 1292 | }; |
1304 | long ret; | 1293 | long ret; |
1305 | 1294 | ||
1295 | if (unlikely(!(out->f_mode & FMODE_WRITE))) | ||
1296 | return -EBADF; | ||
1297 | |||
1298 | if (unlikely(out->f_flags & O_APPEND)) | ||
1299 | return -EINVAL; | ||
1300 | |||
1301 | ret = rw_verify_area(WRITE, out, opos, len); | ||
1302 | if (unlikely(ret < 0)) | ||
1303 | return ret; | ||
1304 | |||
1306 | ret = splice_direct_to_actor(in, &sd, direct_splice_actor); | 1305 | ret = splice_direct_to_actor(in, &sd, direct_splice_actor); |
1307 | if (ret > 0) | 1306 | if (ret > 0) |
1308 | *ppos = sd.pos; | 1307 | *ppos = sd.pos; |
@@ -1358,6 +1357,16 @@ static long do_splice(struct file *in, loff_t __user *off_in, | |||
1358 | offset = out->f_pos; | 1357 | offset = out->f_pos; |
1359 | } | 1358 | } |
1360 | 1359 | ||
1360 | if (unlikely(!(out->f_mode & FMODE_WRITE))) | ||
1361 | return -EBADF; | ||
1362 | |||
1363 | if (unlikely(out->f_flags & O_APPEND)) | ||
1364 | return -EINVAL; | ||
1365 | |||
1366 | ret = rw_verify_area(WRITE, out, &offset, len); | ||
1367 | if (unlikely(ret < 0)) | ||
1368 | return ret; | ||
1369 | |||
1361 | file_start_write(out); | 1370 | file_start_write(out); |
1362 | ret = do_splice_from(ipipe, out, &offset, len, flags); | 1371 | ret = do_splice_from(ipipe, out, &offset, len, flags); |
1363 | file_end_write(out); | 1372 | file_end_write(out); |