diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-09-22 16:27:52 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-10-24 23:34:54 -0400 |
commit | 72c2d53192004845cbc19cd8a30b3212a9288140 (patch) | |
tree | 31fcd924438f03d5aa09d13ffd813fb153da37c3 /fs/read_write.c | |
parent | 22bd002ee76aa7d7a3393f39d977f6c106153c60 (diff) |
file->f_op is never NULL...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/read_write.c')
-rw-r--r-- | fs/read_write.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/fs/read_write.c b/fs/read_write.c index e3cd280b158c..58e440df1bc6 100644 --- a/fs/read_write.c +++ b/fs/read_write.c | |||
@@ -257,7 +257,7 @@ loff_t vfs_llseek(struct file *file, loff_t offset, int whence) | |||
257 | 257 | ||
258 | fn = no_llseek; | 258 | fn = no_llseek; |
259 | if (file->f_mode & FMODE_LSEEK) { | 259 | if (file->f_mode & FMODE_LSEEK) { |
260 | if (file->f_op && file->f_op->llseek) | 260 | if (file->f_op->llseek) |
261 | fn = file->f_op->llseek; | 261 | fn = file->f_op->llseek; |
262 | } | 262 | } |
263 | return fn(file, offset, whence); | 263 | return fn(file, offset, whence); |
@@ -384,7 +384,7 @@ ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos) | |||
384 | 384 | ||
385 | if (!(file->f_mode & FMODE_READ)) | 385 | if (!(file->f_mode & FMODE_READ)) |
386 | return -EBADF; | 386 | return -EBADF; |
387 | if (!file->f_op || (!file->f_op->read && !file->f_op->aio_read)) | 387 | if (!file->f_op->read && !file->f_op->aio_read) |
388 | return -EINVAL; | 388 | return -EINVAL; |
389 | if (unlikely(!access_ok(VERIFY_WRITE, buf, count))) | 389 | if (unlikely(!access_ok(VERIFY_WRITE, buf, count))) |
390 | return -EFAULT; | 390 | return -EFAULT; |
@@ -433,7 +433,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t | |||
433 | const char __user *p; | 433 | const char __user *p; |
434 | ssize_t ret; | 434 | ssize_t ret; |
435 | 435 | ||
436 | if (!file->f_op || (!file->f_op->write && !file->f_op->aio_write)) | 436 | if (!file->f_op->write && !file->f_op->aio_write) |
437 | return -EINVAL; | 437 | return -EINVAL; |
438 | 438 | ||
439 | old_fs = get_fs(); | 439 | old_fs = get_fs(); |
@@ -460,7 +460,7 @@ ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_ | |||
460 | 460 | ||
461 | if (!(file->f_mode & FMODE_WRITE)) | 461 | if (!(file->f_mode & FMODE_WRITE)) |
462 | return -EBADF; | 462 | return -EBADF; |
463 | if (!file->f_op || (!file->f_op->write && !file->f_op->aio_write)) | 463 | if (!file->f_op->write && !file->f_op->aio_write) |
464 | return -EINVAL; | 464 | return -EINVAL; |
465 | if (unlikely(!access_ok(VERIFY_READ, buf, count))) | 465 | if (unlikely(!access_ok(VERIFY_READ, buf, count))) |
466 | return -EFAULT; | 466 | return -EFAULT; |
@@ -727,11 +727,6 @@ static ssize_t do_readv_writev(int type, struct file *file, | |||
727 | io_fn_t fn; | 727 | io_fn_t fn; |
728 | iov_fn_t fnv; | 728 | iov_fn_t fnv; |
729 | 729 | ||
730 | if (!file->f_op) { | ||
731 | ret = -EINVAL; | ||
732 | goto out; | ||
733 | } | ||
734 | |||
735 | ret = rw_copy_check_uvector(type, uvector, nr_segs, | 730 | ret = rw_copy_check_uvector(type, uvector, nr_segs, |
736 | ARRAY_SIZE(iovstack), iovstack, &iov); | 731 | ARRAY_SIZE(iovstack), iovstack, &iov); |
737 | if (ret <= 0) | 732 | if (ret <= 0) |
@@ -778,7 +773,7 @@ ssize_t vfs_readv(struct file *file, const struct iovec __user *vec, | |||
778 | { | 773 | { |
779 | if (!(file->f_mode & FMODE_READ)) | 774 | if (!(file->f_mode & FMODE_READ)) |
780 | return -EBADF; | 775 | return -EBADF; |
781 | if (!file->f_op || (!file->f_op->aio_read && !file->f_op->read)) | 776 | if (!file->f_op->aio_read && !file->f_op->read) |
782 | return -EINVAL; | 777 | return -EINVAL; |
783 | 778 | ||
784 | return do_readv_writev(READ, file, vec, vlen, pos); | 779 | return do_readv_writev(READ, file, vec, vlen, pos); |
@@ -791,7 +786,7 @@ ssize_t vfs_writev(struct file *file, const struct iovec __user *vec, | |||
791 | { | 786 | { |
792 | if (!(file->f_mode & FMODE_WRITE)) | 787 | if (!(file->f_mode & FMODE_WRITE)) |
793 | return -EBADF; | 788 | return -EBADF; |
794 | if (!file->f_op || (!file->f_op->aio_write && !file->f_op->write)) | 789 | if (!file->f_op->aio_write && !file->f_op->write) |
795 | return -EINVAL; | 790 | return -EINVAL; |
796 | 791 | ||
797 | return do_readv_writev(WRITE, file, vec, vlen, pos); | 792 | return do_readv_writev(WRITE, file, vec, vlen, pos); |
@@ -906,10 +901,6 @@ static ssize_t compat_do_readv_writev(int type, struct file *file, | |||
906 | io_fn_t fn; | 901 | io_fn_t fn; |
907 | iov_fn_t fnv; | 902 | iov_fn_t fnv; |
908 | 903 | ||
909 | ret = -EINVAL; | ||
910 | if (!file->f_op) | ||
911 | goto out; | ||
912 | |||
913 | ret = -EFAULT; | 904 | ret = -EFAULT; |
914 | if (!access_ok(VERIFY_READ, uvector, nr_segs*sizeof(*uvector))) | 905 | if (!access_ok(VERIFY_READ, uvector, nr_segs*sizeof(*uvector))) |
915 | goto out; | 906 | goto out; |
@@ -965,7 +956,7 @@ static size_t compat_readv(struct file *file, | |||
965 | goto out; | 956 | goto out; |
966 | 957 | ||
967 | ret = -EINVAL; | 958 | ret = -EINVAL; |
968 | if (!file->f_op || (!file->f_op->aio_read && !file->f_op->read)) | 959 | if (!file->f_op->aio_read && !file->f_op->read) |
969 | goto out; | 960 | goto out; |
970 | 961 | ||
971 | ret = compat_do_readv_writev(READ, file, vec, vlen, pos); | 962 | ret = compat_do_readv_writev(READ, file, vec, vlen, pos); |
@@ -1032,7 +1023,7 @@ static size_t compat_writev(struct file *file, | |||
1032 | goto out; | 1023 | goto out; |
1033 | 1024 | ||
1034 | ret = -EINVAL; | 1025 | ret = -EINVAL; |
1035 | if (!file->f_op || (!file->f_op->aio_write && !file->f_op->write)) | 1026 | if (!file->f_op->aio_write && !file->f_op->write) |
1036 | goto out; | 1027 | goto out; |
1037 | 1028 | ||
1038 | ret = compat_do_readv_writev(WRITE, file, vec, vlen, pos); | 1029 | ret = compat_do_readv_writev(WRITE, file, vec, vlen, pos); |