diff options
-rw-r--r-- | fs/9p/vfs_file.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index e97c92bd6f16..89c44e92022c 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c | |||
@@ -219,7 +219,9 @@ static ssize_t | |||
219 | v9fs_file_write(struct file *filp, const char __user * data, | 219 | v9fs_file_write(struct file *filp, const char __user * data, |
220 | size_t count, loff_t * offset) | 220 | size_t count, loff_t * offset) |
221 | { | 221 | { |
222 | int n, rsize, total = 0; | 222 | ssize_t retval; |
223 | size_t total = 0; | ||
224 | int n, rsize; | ||
223 | struct p9_fid *fid; | 225 | struct p9_fid *fid; |
224 | struct p9_client *clnt; | 226 | struct p9_client *clnt; |
225 | struct inode *inode = filp->f_path.dentry->d_inode; | 227 | struct inode *inode = filp->f_path.dentry->d_inode; |
@@ -234,6 +236,17 @@ v9fs_file_write(struct file *filp, const char __user * data, | |||
234 | 236 | ||
235 | rsize = fid->iounit ? fid->iounit : clnt->msize - P9_IOHDRSZ; | 237 | rsize = fid->iounit ? fid->iounit : clnt->msize - P9_IOHDRSZ; |
236 | 238 | ||
239 | retval = generic_write_checks(filp, &origin, &count, 0); | ||
240 | if (retval) | ||
241 | goto out; | ||
242 | |||
243 | retval = -EINVAL; | ||
244 | if ((ssize_t) count < 0) | ||
245 | goto out; | ||
246 | retval = 0; | ||
247 | if (!count) | ||
248 | goto out; | ||
249 | |||
237 | do { | 250 | do { |
238 | if (count < rsize) | 251 | if (count < rsize) |
239 | rsize = count; | 252 | rsize = count; |
@@ -258,9 +271,11 @@ v9fs_file_write(struct file *filp, const char __user * data, | |||
258 | } | 271 | } |
259 | 272 | ||
260 | if (n < 0) | 273 | if (n < 0) |
261 | return n; | 274 | retval = n; |
262 | 275 | else | |
263 | return total; | 276 | retval = total; |
277 | out: | ||
278 | return retval; | ||
264 | } | 279 | } |
265 | 280 | ||
266 | static int v9fs_file_fsync(struct file *filp, int datasync) | 281 | static int v9fs_file_fsync(struct file *filp, int datasync) |