From: Liviu Dudau Date: Tue, 5 Mar 2019 23:42:54 +0000 (-0800) Subject: mm/vmalloc.c: don't dereference possible NULL pointer in __vunmap() X-Git-Tag: v5.1-rc1~152^2~133 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=6ade20327dbb808882888ed8ccded71e93067cf9;p=uclinux-h8%2Flinux.git mm/vmalloc.c: don't dereference possible NULL pointer in __vunmap() find_vmap_area() can return a NULL pointer and we're going to dereference it without checking it first. Use the existing find_vm_area() function which does exactly what we want and checks for the NULL pointer. Link: http://lkml.kernel.org/r/20181228171009.22269-1-liviu@dudau.co.uk Fixes: f3c01d2f3ade ("mm: vmalloc: avoid racy handling of debugobjects in vunmap") Signed-off-by: Liviu Dudau Reviewed-by: Andrew Morton Cc: Chintan Pandya Cc: Andrey Ryabinin Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 871e41c55e23..806047d7fda3 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1505,7 +1505,7 @@ static void __vunmap(const void *addr, int deallocate_pages) addr)) return; - area = find_vmap_area((unsigned long)addr)->vm; + area = find_vm_area(addr); if (unlikely(!area)) { WARN(1, KERN_ERR "Trying to vfree() nonexistent vm area (%p)\n", addr);