mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
Slab allocators: fail if ksize is called with a NULL parameter
A NULL pointer means that the object was not allocated. One cannot determine the size of an object that has not been allocated. Currently we return 0 but we really should BUG() on attempts to determine the size of something nonexistent. krealloc() interprets NULL to mean a zero sized object. Handle that separately in krealloc(). Signed-off-by: Christoph Lameter <[email protected]> Acked-by: Pekka Enberg <[email protected]> Cc: Matt Mackall <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
0da7e01f5f
commit
ef8b4520bd
4 changed files with 10 additions and 5 deletions
|
|
@ -484,7 +484,8 @@ size_t ksize(const void *block)
|
|||
{
|
||||
struct slob_page *sp;
|
||||
|
||||
if (unlikely(ZERO_OR_NULL_PTR(block)))
|
||||
BUG_ON(!block);
|
||||
if (unlikely(block == ZERO_SIZE_PTR))
|
||||
return 0;
|
||||
|
||||
sp = (struct slob_page *)virt_to_page(block);
|
||||
|
|
|
|||
Loading…
Reference in a new issue