Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

binfmt_misc: use simple_read_from_buffer()

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Akinobu Mita and committed by
Linus Torvalds
6e2c10a1 76a6f3dc

+3 -17
+3 -17
fs/binfmt_misc.c
··· 27 27 #include <linux/namei.h> 28 28 #include <linux/mount.h> 29 29 #include <linux/syscalls.h> 30 + #include <linux/fs.h> 30 31 31 32 #include <asm/uaccess.h> 32 33 ··· 536 535 bm_entry_read(struct file * file, char __user * buf, size_t nbytes, loff_t *ppos) 537 536 { 538 537 Node *e = file->f_path.dentry->d_inode->i_private; 539 - loff_t pos = *ppos; 540 538 ssize_t res; 541 539 char *page; 542 - int len; 543 540 544 541 if (!(page = (char*) __get_free_page(GFP_KERNEL))) 545 542 return -ENOMEM; 546 543 547 544 entry_status(e, page); 548 - len = strlen(page); 549 545 550 - res = -EINVAL; 551 - if (pos < 0) 552 - goto out; 553 - res = 0; 554 - if (pos >= len) 555 - goto out; 556 - if (len < pos + nbytes) 557 - nbytes = len - pos; 558 - res = -EFAULT; 559 - if (copy_to_user(buf, page + pos, nbytes)) 560 - goto out; 561 - *ppos = pos + nbytes; 562 - res = nbytes; 563 - out: 546 + res = simple_read_from_buffer(buf, nbytes, ppos, page, strlen(page)); 547 + 564 548 free_page((unsigned long) page); 565 549 return res; 566 550 }