Skip to content

Commit e59464c

Browse files
xiaosuotorvalds
authored andcommitted
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: Changli Gao <xiaosuo@gmail.com> Cc: Patrick McHardy <kaber@trash.net> Acked-by: David Rientjes <rientjes@google.com> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 46da276 commit e59464c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎lib/flex_array.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ struct flex_array *flex_array_alloc(int element_size, unsigned int total,
9999
ret->element_size = element_size;
100100
ret->total_nr_elements = total;
101101
if (elements_fit_in_base(ret) && !(flags & __GFP_ZERO))
102-
memset(ret->parts[0], FLEX_ARRAY_FREE,
102+
memset(&ret->parts[0], FLEX_ARRAY_FREE,
103103
FLEX_ARRAY_BASE_BYTES_LEFT);
104104
return ret;
105105
}

0 commit comments

Comments
 (0)