@@ -88,7 +88,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8888 unsigned long len , unsigned long pgoff , unsigned long flags )
8989{
9090 struct mm_struct * mm = current -> mm ;
91- struct vm_area_struct * vma ;
91+ struct vm_area_struct * vma , * prev ;
9292 unsigned long task_size = TASK_SIZE ;
9393 int do_color_align , last_mmap ;
9494 struct vm_unmapped_area_info info ;
@@ -115,9 +115,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
115115 else
116116 addr = PAGE_ALIGN (addr );
117117
118- vma = find_vma (mm , addr );
118+ vma = find_vma_prev (mm , addr , & prev );
119119 if (task_size - len >= addr &&
120- (!vma || addr + len <= vma -> vm_start ))
120+ (!vma || addr + len <= vm_start_gap (vma )) &&
121+ (!prev || addr >= vm_end_gap (prev )))
121122 goto found_addr ;
122123 }
123124
@@ -141,7 +142,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
141142 const unsigned long len , const unsigned long pgoff ,
142143 const unsigned long flags )
143144{
144- struct vm_area_struct * vma ;
145+ struct vm_area_struct * vma , * prev ;
145146 struct mm_struct * mm = current -> mm ;
146147 unsigned long addr = addr0 ;
147148 int do_color_align , last_mmap ;
@@ -175,9 +176,11 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
175176 addr = COLOR_ALIGN (addr , last_mmap , pgoff );
176177 else
177178 addr = PAGE_ALIGN (addr );
178- vma = find_vma (mm , addr );
179+
180+ vma = find_vma_prev (mm , addr , & prev );
179181 if (TASK_SIZE - len >= addr &&
180- (!vma || addr + len <= vma -> vm_start ))
182+ (!vma || addr + len <= vm_start_gap (vma )) &&
183+ (!prev || addr >= vm_end_gap (prev )))
181184 goto found_addr ;
182185 }
183186
0 commit comments