From: Changli Gao Date: Fri, 23 Apr 2010 17:17:45 +0000 (-0400) Subject: flex_array: fix the panic when calling flex_array_alloc() without __GFP_ZERO X-Git-Tag: v2.6.32.13~88 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=669805f0492eb6415a6c621fcd1ef6e29fee32b8;p=karo-tx-linux.git flex_array: fix the panic when calling flex_array_alloc() without __GFP_ZERO commit e59464c735db19619cde2aa331609adb02005f5b upstream. memset() is called with the wrong address and the kernel panics. Signed-off-by: Changli Gao Cc: Patrick McHardy Acked-by: David Rientjes Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- diff --git a/lib/flex_array.c b/lib/flex_array.c index 66eef2e4483e..41b1804fa728 100644 --- a/lib/flex_array.c +++ b/lib/flex_array.c @@ -99,7 +99,7 @@ struct flex_array *flex_array_alloc(int element_size, unsigned int total, ret->element_size = element_size; ret->total_nr_elements = total; if (elements_fit_in_base(ret) && !(flags & __GFP_ZERO)) - memset(ret->parts[0], FLEX_ARRAY_FREE, + memset(&ret->parts[0], FLEX_ARRAY_FREE, FLEX_ARRAY_BASE_BYTES_LEFT); return ret; }