flex_arrays: allow zero length flex arrays
authorEric Paris <eparis@redhat.com>
Thu, 28 Apr 2011 19:55:52 +0000 (15:55 -0400)
committerSteve Conklin <sconklin@canonical.com>
Thu, 2 Jun 2011 19:23:15 +0000 (14:23 -0500)
commitce9a3c8440b09b8e921decf45d8c4064bf1fe86e
treeb13d78c175bb8c8b0ebce36b64c89926929a2d4f
parent8718a057e8148f075deddec228b0da0f5d82dd06
flex_arrays: allow zero length flex arrays

BugLink: http://bugs.launchpad.net/bugs/780546

commit bf69d41d198138e3c601e9a6645f4f1369aff7e0 upstream.

Just like kmalloc will allow one to allocate a 0 length segment of memory
flex arrays should do the same thing.  It should bomb if you try to use
something, but it should at least allow the allocation.

This is needed because when SELinux switched to using flex_arrays in 2.6.38
the inability to allocate a 0 length array resulted in SELinux policy load
returning -ENOSPC when previously it worked.

Based-on-patch-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
Tested-by: Chris Richards <gizmo@giz-works.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
lib/flex_array.c