David Rientjes a30b595d2c flex_array: fix get function for elements in base starting at non-zero
If all array elements fit into the base structure and data is copied using
flex_array_put() starting at a non-zero index, flex_array_get() will fail
to return the data.

This fixes the bug by only checking for NULL parts when all elements do
not fit in the base structure when flex_array_get() is used.  Otherwise,
fa_element_to_part_nr() will always be 0 since there are no parts
structures needed and such element may never have been put.  Thus, it will
remain NULL due to the kzalloc() of the base.

Additionally, flex_array_put() now only checks for a NULL part when all
elements do not fit in the base structure.  This is otherwise unnecessary
since the base structure is guaranteed to exist (or we would have already
hit a NULL pointer).

Signed-off-by: David Rientjes <rientjes@google.com>
Acked-by: Dave Hansen <dave@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-08-26 20:06:52 -07:00
..
2009-06-19 14:58:13 +02:00
2009-07-28 13:45:22 -07:00
2009-01-06 15:59:11 -08:00
2009-01-01 10:12:19 +10:30
2009-06-18 13:04:05 -07:00
2009-06-16 19:47:51 -07:00
2009-04-02 19:04:53 -07:00
2008-07-26 12:00:07 -07:00
2009-02-11 13:38:00 +11:00
2009-07-29 19:10:36 -07:00
2008-07-26 12:00:07 -07:00
2008-07-30 16:29:19 -07:00
2008-07-26 12:00:10 -07:00
2008-07-26 12:00:10 -07:00