Re: [Patch] mm/sparse.c: Check the return value ofsparse_index_alloc().

From: Andrew Morton
Date: Fri Nov 16 2007 - 16:37:46 EST


On Thu, 15 Nov 2007 21:54:28 +0800
WANG Cong <xiyou.wangcong@xxxxxxxxx> wrote:

>
> 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 <xiyou.wangcong@xxxxxxxxx>
> Cc: Christoph Lameter <clameter@xxxxxxx>
> Cc: Rik van Riel <riel@xxxxxxxxxx>
>
> ---
>
> diff --git a/Makefile b/Makefile
> diff --git a/mm/sparse.c b/mm/sparse.c
> index e06f514..d245e59 100644
> --- a/mm/sparse.c
> +++ b/mm/sparse.c
> @@ -83,6 +83,8 @@ static int __meminit sparse_index_init(unsigned long section_nr, int nid)
> return -EEXIST;
>
> section = sparse_index_alloc(nid);
> + if (!section)
> + return -ENOMEM;
> /*
> * This lock keeps two different sections from
> * reallocating for the same index

Sure, but both callers of sparse_index_init() ignore its return value anyway.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/