From: WANG Cong Since sparse_index_alloc() can return NULL on memory allocation failure, we must deal with the failure condition when calling it. Signed-off-by: WANG Cong Cc: Christoph Lameter Cc: Rik van Riel Signed-off-by: Andrew Morton --- mm/sparse.c | 2 ++ 1 file changed, 2 insertions(+) diff -puN mm/sparse.c~mm-sparsec-check-the-return-value-of-sparse_index_alloc mm/sparse.c --- a/mm/sparse.c~mm-sparsec-check-the-return-value-of-sparse_index_alloc +++ a/mm/sparse.c @@ -83,6 +83,8 @@ static int __meminit sparse_index_init(u return -EEXIST; section = sparse_index_alloc(nid); + if (!section) + return -ENOMEM; /* * This lock keeps two different sections from * reallocating for the same index _