From c6a8796eac01434dd47de13561d99e3415993657 Mon Sep 17 00:00:00 2001 From: Liviu Dudau Date: Fri, 20 Sep 2019 11:25:12 -0700 Subject: [PATCH] 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. Change-Id: I9b58c7423edb7927b64b722de886f8bc98c5f9ca Git-commit: 6ade20327dbb808882888ed8ccded71e93067cf9 Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 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 Signed-off-by: Prakruthi Deepak Heragu --- mm/vmalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index d067e1779e4c..0f8988ff7672 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1530,7 +1530,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);