Skip to content

Commit

Permalink
mm: vmalloc: check for page allocation failure before vmlist insertion
Browse files Browse the repository at this point in the history
Commit f5252e0 ("mm: avoid null pointer access in vm_struct via
/proc/vmallocinfo") adds newly allocated vm_structs to the vmlist after
it is fully initialised.  Unfortunately, it did not check that
__vmalloc_area_node() successfully populated the area.  In the event of
allocation failure, the vmalloc area is freed but the pointer to freed
memory is inserted into the vmlist leading to a a crash later in
get_vmalloc_info().

This patch adds a check for ____vmalloc_area_node() failure within
__vmalloc_node_range.  It does not use "goto fail" as in the previous
error path as a warning was already displayed by __vmalloc_area_node()
before it called vfree in its failure path.

Credit goes to Luciano Chavez for doing all the real work of identifying
exactly where the problem was.

Signed-off-by: Mel Gorman <[email protected]>
Reported-by: Luciano Chavez <[email protected]>
Tested-by: Luciano Chavez <[email protected]>
Reviewed-by: Rik van Riel <[email protected]>
Acked-by: David Rientjes <[email protected]>
Cc: <[email protected]>		[3.1.x+]
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Mel Gorman authored and torvalds committed Dec 9, 2011
1 parent d021563 commit 1368edf
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mm/vmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1633,6 +1633,8 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
goto fail;

addr = __vmalloc_area_node(area, gfp_mask, prot, node, caller);
if (!addr)
return NULL;

/*
* In this function, newly allocated vm_struct is not added
Expand Down

0 comments on commit 1368edf

Please sign in to comment.