]> Git Repo - linux.git/commit
flex_array: convert element_nr formals to unsigned
authorDavid Rientjes <[email protected]>
Wed, 26 Aug 2009 21:29:22 +0000 (14:29 -0700)
committerLinus Torvalds <[email protected]>
Thu, 27 Aug 2009 03:06:52 +0000 (20:06 -0700)
commitb62e408c05228f40e69bb38a48db8961cac6cd23
tree40711bad4a60adb8f331d71574ec61e13c5a352d
parent8e7ee27095aee87b5db1b0061e2ceea5878a1bbd
flex_array: convert element_nr formals to unsigned

It's problematic to allow signed element_nr's or total's to be passed as
part of the flex array API.

flex_array_alloc() allows total_nr_elements to be set to a negative
quantity, which is obviously erroneous.

flex_array_get() and flex_array_put() allows negative array indices in
dereferencing an array part, which could address memory mapped before
struct flex_array.

The fix is to convert all existing element_nr formals to be qualified as
unsigned.  Existing checks to compare it to total_nr_elements or the max
array size based on element_size need not be changed.

Signed-off-by: David Rientjes <[email protected]>
Cc: Dave Hansen <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
include/linux/flex_array.h
lib/flex_array.c
This page took 0.064645 seconds and 4 git commands to generate.