Skip to content

Commit 7511c3e

Browse files
jeromemarchandtorvalds
authored andcommitted
mm: vmalloc: don't remove inexistent guard hole in remove_vm_area()
Commit 71394fe ("mm: vmalloc: add flag preventing guard hole allocation") missed a spot. Currently remove_vm_area() decreases vm->size to "remove" the guard hole page, even when it isn't present. All but one users just free the vm_struct rigth away and never access vm->size anyway. Don't touch the size in remove_vm_area() and have __vunmap() use the proper get_vm_area_size() helper. Signed-off-by: Jerome Marchand <jmarchan@redhat.com> Acked-by: Andrey Ryabinin <aryabinin@virtuozzo.com> Acked-by: David Rientjes <rientjes@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 429d486 commit 7511c3e

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

‎mm/vmalloc.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,7 +1443,6 @@ struct vm_struct *remove_vm_area(const void *addr)
14431443
vmap_debug_free_range(va->va_start, va->va_end);
14441444
kasan_free_shadow(vm);
14451445
free_unmap_vmap_area(va);
1446-
vm->size -= PAGE_SIZE;
14471446

14481447
return vm;
14491448
}
@@ -1468,8 +1467,8 @@ static void __vunmap(const void *addr, int deallocate_pages)
14681467
return;
14691468
}
14701469

1471-
debug_check_no_locks_freed(addr, area->size);
1472-
debug_check_no_obj_freed(addr, area->size);
1470+
debug_check_no_locks_freed(addr, get_vm_area_size(area));
1471+
debug_check_no_obj_freed(addr, get_vm_area_size(area));
14731472

14741473
if (deallocate_pages) {
14751474
int i;

0 commit comments

Comments
 (0)