diff options
author | Eric Paris <eparis@redhat.com> | 2011-04-28 15:55:52 -0400 |
---|---|---|
committer | Eric Paris <eparis@redhat.com> | 2011-04-28 15:56:07 -0400 |
commit | a8d05c81fb238bbb18878ccfae7599ca79448dd3 (patch) | |
tree | b66baaf076be8f830cc07fb02ad22e2b3a9dd3e2 /fs/xattr.c | |
parent | 150cdf6ec0ede8d9f102f1817212447727dcf08c (diff) | |
download | op-kernel-dev-a8d05c81fb238bbb18878ccfae7599ca79448dd3.zip op-kernel-dev-a8d05c81fb238bbb18878ccfae7599ca79448dd3.tar.gz |
flex_array: allow 0 length elements
flex_arrays are supposed to be a replacement for:
kmalloc(num_elements * sizeof(element))
If kmalloc is given 0 num_elements or a 0 size element it will happily return
ZERO_SIZE_PTR. Which looks like a valid allocation, but which will explode if
something actually try to use it. The current flex_array code will return an
equivalent result if num_elements is 0, but will fail to work if
sizeof(element) is 0. This patch allows allocation to work even for 0 size
elements. It will cause flex_arrays to explode though if they are used.
Imitating the kmalloc behavior.
Based-on-patch-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dave Hansen <dave@linux.vnet.ibm.com>
Diffstat (limited to 'fs/xattr.c')
0 files changed, 0 insertions, 0 deletions