Re: SLUB: Return ZERO_SIZE_PTR for kmalloc(0)

From: Alan Cox
Date: Mon Jun 04 2007 - 10:43:01 EST


> > > I agree the risk is low, but if something _does_ blow up, it will do so subtly.
>
> Arguable the proposed badptr behavior is correct. It's basically "how many
> angels can dance on the head of a pin"? All the returned pointers are
> at least 0 bytes away from the previous one.

C++ very carefully keeps objects of zero size at differing addresses to
avoid exactly this kind of pointer confusion. Given the trivial fix is
simply

size += !size;

at the start of malloc what is there worth arguing about ?

-
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/