diff options
author | Kinglong Mee <kinglongmee@gmail.com> | 2014-04-08 01:04:01 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2014-05-08 14:59:52 -0400 |
commit | f3e41ec5ef0f5d2e10b6bfd3a13dc29f6d260d79 (patch) | |
tree | d4db00c55fa5f792fefc5fb560cff40b49065b69 | |
parent | ecca063b31b88d31ee79e9d958ea78023659554e (diff) |
NFSD: Use simple_read_from_buffer for coping data to userspace
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
-rw-r--r-- | fs/nfsd/fault_inject.c | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/fs/nfsd/fault_inject.c b/fs/nfsd/fault_inject.c index d620e7f81429..2ed05c3cd43d 100644 --- a/fs/nfsd/fault_inject.c +++ b/fs/nfsd/fault_inject.c | |||
@@ -97,25 +97,14 @@ static ssize_t fault_inject_read(struct file *file, char __user *buf, | |||
97 | { | 97 | { |
98 | static u64 val; | 98 | static u64 val; |
99 | char read_buf[25]; | 99 | char read_buf[25]; |
100 | size_t size, ret; | 100 | size_t size; |
101 | loff_t pos = *ppos; | 101 | loff_t pos = *ppos; |
102 | 102 | ||
103 | if (!pos) | 103 | if (!pos) |
104 | nfsd_inject_get(file_inode(file)->i_private, &val); | 104 | nfsd_inject_get(file_inode(file)->i_private, &val); |
105 | size = scnprintf(read_buf, sizeof(read_buf), "%llu\n", val); | 105 | size = scnprintf(read_buf, sizeof(read_buf), "%llu\n", val); |
106 | 106 | ||
107 | if (pos < 0) | 107 | return simple_read_from_buffer(buf, len, ppos, read_buf, size); |
108 | return -EINVAL; | ||
109 | if (pos >= size || !len) | ||
110 | return 0; | ||
111 | if (len > size - pos) | ||
112 | len = size - pos; | ||
113 | ret = copy_to_user(buf, read_buf + pos, len); | ||
114 | if (ret == len) | ||
115 | return -EFAULT; | ||
116 | len -= ret; | ||
117 | *ppos = pos + len; | ||
118 | return len; | ||
119 | } | 108 | } |
120 | 109 | ||
121 | static ssize_t fault_inject_write(struct file *file, const char __user *buf, | 110 | static ssize_t fault_inject_write(struct file *file, const char __user *buf, |