Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <liviu@dudau.co.uk>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Chintan Pandya <cpandya@codeaurora.org>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Liviu Dudau and committed by
Linus Torvalds
6ade2032 abd02ac6

+1 -1
+1 -1
mm/vmalloc.c
··· 1505 1505 addr)) 1506 1506 return; 1507 1507 1508 - area = find_vmap_area((unsigned long)addr)->vm; 1508 + area = find_vm_area(addr); 1509 1509 if (unlikely(!area)) { 1510 1510 WARN(1, KERN_ERR "Trying to vfree() nonexistent vm area (%p)\n", 1511 1511 addr);