Commit e59464c7 authored by Changli Gao's avatar Changli Gao Committed by Linus Torvalds

flex_array: fix the panic when calling flex_array_alloc() without __GFP_ZERO

memset() is called with the wrong address and the kernel panics.
Signed-off-by: default avatarChangli Gao <xiaosuo@gmail.com>
Cc: Patrick McHardy <kaber@trash.net>
Acked-by: default avatarDavid Rientjes <rientjes@google.com>
Cc: <stable@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 46da2766
...@@ -99,7 +99,7 @@ struct flex_array *flex_array_alloc(int element_size, unsigned int total, ...@@ -99,7 +99,7 @@ struct flex_array *flex_array_alloc(int element_size, unsigned int total,
ret->element_size = element_size; ret->element_size = element_size;
ret->total_nr_elements = total; ret->total_nr_elements = total;
if (elements_fit_in_base(ret) && !(flags & __GFP_ZERO)) 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); FLEX_ARRAY_BASE_BYTES_LEFT);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment