aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mm/mmap.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/mm/mmap.c b/mm/mmap.c
index f8c61b2385ff..0fa87a5ae2cc 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1602,14 +1602,13 @@ static void unmap_vma(struct mm_struct *mm, struct vm_area_struct *area)
1602 * Ok - we have the memory areas we should free on the 'free' list, 1602 * Ok - we have the memory areas we should free on the 'free' list,
1603 * so release them, and do the vma updates. 1603 * so release them, and do the vma updates.
1604 */ 1604 */
1605static void unmap_vma_list(struct mm_struct *mm, 1605static void unmap_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
1606 struct vm_area_struct *mpnt)
1607{ 1606{
1608 do { 1607 do {
1609 struct vm_area_struct *next = mpnt->vm_next; 1608 struct vm_area_struct *next = vma->vm_next;
1610 unmap_vma(mm, mpnt); 1609 unmap_vma(mm, vma);
1611 mpnt = next; 1610 vma = next;
1612 } while (mpnt != NULL); 1611 } while (vma);
1613 validate_mm(mm); 1612 validate_mm(mm);
1614} 1613}
1615 1614
@@ -1720,7 +1719,7 @@ int split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
1720int do_munmap(struct mm_struct *mm, unsigned long start, size_t len) 1719int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
1721{ 1720{
1722 unsigned long end; 1721 unsigned long end;
1723 struct vm_area_struct *mpnt, *prev, *last; 1722 struct vm_area_struct *vma, *prev, *last;
1724 1723
1725 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start) 1724 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
1726 return -EINVAL; 1725 return -EINVAL;
@@ -1729,14 +1728,14 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
1729 return -EINVAL; 1728 return -EINVAL;
1730 1729
1731 /* Find the first overlapping VMA */ 1730 /* Find the first overlapping VMA */
1732 mpnt = find_vma_prev(mm, start, &prev); 1731 vma = find_vma_prev(mm, start, &prev);
1733 if (!mpnt) 1732 if (!vma)
1734 return 0; 1733 return 0;
1735 /* we have start < mpnt->vm_end */ 1734 /* we have start < vma->vm_end */
1736 1735
1737 /* if it doesn't overlap, we have nothing.. */ 1736 /* if it doesn't overlap, we have nothing.. */
1738 end = start + len; 1737 end = start + len;
1739 if (mpnt->vm_start >= end) 1738 if (vma->vm_start >= end)
1740 return 0; 1739 return 0;
1741 1740
1742 /* 1741 /*
@@ -1746,11 +1745,11 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
1746 * unmapped vm_area_struct will remain in use: so lower split_vma 1745 * unmapped vm_area_struct will remain in use: so lower split_vma
1747 * places tmp vma above, and higher split_vma places tmp vma below. 1746 * places tmp vma above, and higher split_vma places tmp vma below.
1748 */ 1747 */
1749 if (start > mpnt->vm_start) { 1748 if (start > vma->vm_start) {
1750 int error = split_vma(mm, mpnt, start, 0); 1749 int error = split_vma(mm, vma, start, 0);
1751 if (error) 1750 if (error)
1752 return error; 1751 return error;
1753 prev = mpnt; 1752 prev = vma;
1754 } 1753 }
1755 1754
1756 /* Does it split the last one? */ 1755 /* Does it split the last one? */
@@ -1760,16 +1759,16 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
1760 if (error) 1759 if (error)
1761 return error; 1760 return error;
1762 } 1761 }
1763 mpnt = prev? prev->vm_next: mm->mmap; 1762 vma = prev? prev->vm_next: mm->mmap;
1764 1763
1765 /* 1764 /*
1766 * Remove the vma's, and unmap the actual pages 1765 * Remove the vma's, and unmap the actual pages
1767 */ 1766 */
1768 detach_vmas_to_be_unmapped(mm, mpnt, prev, end); 1767 detach_vmas_to_be_unmapped(mm, vma, prev, end);
1769 unmap_region(mm, mpnt, prev, start, end); 1768 unmap_region(mm, vma, prev, start, end);
1770 1769
1771 /* Fix up all other VM information */ 1770 /* Fix up all other VM information */
1772 unmap_vma_list(mm, mpnt); 1771 unmap_vma_list(mm, vma);
1773 1772
1774 return 0; 1773 return 0;
1775} 1774}