diff options
author | Oleg Nesterov <oleg@redhat.com> | 2013-03-24 13:37:48 -0400 |
---|---|---|
committer | Oleg Nesterov <oleg@redhat.com> | 2013-04-04 07:57:05 -0400 |
commit | 2edb7b5574d447354202ba365fb8ca6a1bac1d1c (patch) | |
tree | b26cd1b630261aa7507652975a32510d1a987ee6 /kernel/events/uprobes.c | |
parent | ab0d805c7b9089f9a9b291f33ab95301d6604868 (diff) |
uprobes: Change __copy_insn() to use copy_from_page()
Change __copy_insn() to use copy_from_page() and simplify the code.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Anton Arapov <anton@redhat.com>
Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Diffstat (limited to 'kernel/events/uprobes.c')
-rw-r--r-- | kernel/events/uprobes.c | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 850eb9eb179b..ba6acfe7c0de 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c | |||
@@ -500,30 +500,21 @@ __copy_insn(struct address_space *mapping, struct file *filp, char *insn, | |||
500 | unsigned long nbytes, loff_t offset) | 500 | unsigned long nbytes, loff_t offset) |
501 | { | 501 | { |
502 | struct page *page; | 502 | struct page *page; |
503 | void *vaddr; | ||
504 | unsigned long off; | ||
505 | pgoff_t idx; | ||
506 | 503 | ||
507 | if (!filp) | 504 | if (!filp) |
508 | return -EINVAL; | 505 | return -EINVAL; |
509 | 506 | ||
510 | if (!mapping->a_ops->readpage) | 507 | if (!mapping->a_ops->readpage) |
511 | return -EIO; | 508 | return -EIO; |
512 | |||
513 | idx = offset >> PAGE_CACHE_SHIFT; | ||
514 | off = offset & ~PAGE_MASK; | ||
515 | |||
516 | /* | 509 | /* |
517 | * Ensure that the page that has the original instruction is | 510 | * Ensure that the page that has the original instruction is |
518 | * populated and in page-cache. | 511 | * populated and in page-cache. |
519 | */ | 512 | */ |
520 | page = read_mapping_page(mapping, idx, filp); | 513 | page = read_mapping_page(mapping, offset >> PAGE_CACHE_SHIFT, filp); |
521 | if (IS_ERR(page)) | 514 | if (IS_ERR(page)) |
522 | return PTR_ERR(page); | 515 | return PTR_ERR(page); |
523 | 516 | ||
524 | vaddr = kmap_atomic(page); | 517 | copy_from_page(page, offset, insn, nbytes); |
525 | memcpy(insn, vaddr + off, nbytes); | ||
526 | kunmap_atomic(vaddr); | ||
527 | page_cache_release(page); | 518 | page_cache_release(page); |
528 | 519 | ||
529 | return 0; | 520 | return 0; |