Re: [PATCH v2] flex_array: Change behaviour on zero sizeallocations
From: Dave Hansen
Date: Tue Feb 08 2011 - 12:03:22 EST
On Mon, 2011-02-07 at 13:29 +0100, Steffen Klassert wrote:
> int flex_array_prealloc(struct flex_array *fa, unsigned int start,
> - unsigned int end, gfp_t flags)
> + unsigned int nr_elements, gfp_t flags)
> {
> int start_part;
> int end_part;
> int part_nr;
> + unsigned int end;
> struct flex_array_part *part;
>
> - if (start >= fa->total_nr_elements || end >= fa->total_nr_elements)
> + if (!fa->total_nr_elements && !start)
> + return 0;
> + if (start >= fa->total_nr_elements)
> + return -ENOSPC;
> + if (!nr_elements)
> + return 0;
> +
> + end = start + nr_elements - 1;
> +
> + if (end >= fa->total_nr_elements)
> return -ENOSPC;
> + if (!fa->element_size)
> + return 0;
The rest of this patch looks good. When you resend, you need to break
this up in to at least two patches: one to change 'end' to
'nr_elements' (or something else) and the one to handle zero-sized
elements and arrays.
I also think we need to remove the ability to do zero-sized elements.
Unless there's some new code that I'm missing, I don't see any of the
existing security policy code which would be able to do that.
-- Dave
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/