diff options
-rw-r--r-- | ipc/mqueue.c | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/ipc/mqueue.c b/ipc/mqueue.c index 3e84b958186b..1fdc2eb2f6d8 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c | |||
@@ -314,15 +314,11 @@ static int mqueue_unlink(struct inode *dir, struct dentry *dentry) | |||
314 | * through std routines) | 314 | * through std routines) |
315 | */ | 315 | */ |
316 | static ssize_t mqueue_read_file(struct file *filp, char __user *u_data, | 316 | static ssize_t mqueue_read_file(struct file *filp, char __user *u_data, |
317 | size_t count, loff_t * off) | 317 | size_t count, loff_t *off) |
318 | { | 318 | { |
319 | struct mqueue_inode_info *info = MQUEUE_I(filp->f_path.dentry->d_inode); | 319 | struct mqueue_inode_info *info = MQUEUE_I(filp->f_path.dentry->d_inode); |
320 | char buffer[FILENT_SIZE]; | 320 | char buffer[FILENT_SIZE]; |
321 | size_t slen; | 321 | ssize_t ret; |
322 | loff_t o; | ||
323 | |||
324 | if (!count) | ||
325 | return 0; | ||
326 | 322 | ||
327 | spin_lock(&info->lock); | 323 | spin_lock(&info->lock); |
328 | snprintf(buffer, sizeof(buffer), | 324 | snprintf(buffer, sizeof(buffer), |
@@ -335,21 +331,14 @@ static ssize_t mqueue_read_file(struct file *filp, char __user *u_data, | |||
335 | pid_vnr(info->notify_owner)); | 331 | pid_vnr(info->notify_owner)); |
336 | spin_unlock(&info->lock); | 332 | spin_unlock(&info->lock); |
337 | buffer[sizeof(buffer)-1] = '\0'; | 333 | buffer[sizeof(buffer)-1] = '\0'; |
338 | slen = strlen(buffer)+1; | ||
339 | |||
340 | o = *off; | ||
341 | if (o > slen) | ||
342 | return 0; | ||
343 | |||
344 | if (o + count > slen) | ||
345 | count = slen - o; | ||
346 | 334 | ||
347 | if (copy_to_user(u_data, buffer + o, count)) | 335 | ret = simple_read_from_buffer(u_data, count, off, buffer, |
348 | return -EFAULT; | 336 | strlen(buffer)); |
337 | if (ret <= 0) | ||
338 | return ret; | ||
349 | 339 | ||
350 | *off = o + count; | ||
351 | filp->f_path.dentry->d_inode->i_atime = filp->f_path.dentry->d_inode->i_ctime = CURRENT_TIME; | 340 | filp->f_path.dentry->d_inode->i_atime = filp->f_path.dentry->d_inode->i_ctime = CURRENT_TIME; |
352 | return count; | 341 | return ret; |
353 | } | 342 | } |
354 | 343 | ||
355 | static int mqueue_flush_file(struct file *filp, fl_owner_t id) | 344 | static int mqueue_flush_file(struct file *filp, fl_owner_t id) |