mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 07:12:09 +00: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 <clameter@sgi.com> Acked-by: Pekka Enberg <penberg@cs.helsinki.fi> Cc: Matt Mackall <mpm@selenic.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
0da7e01f5f
commit
ef8b4520bd
4 changed files with 10 additions and 5 deletions
|
@ -4446,7 +4446,8 @@ const struct seq_operations slabstats_op = {
|
|||
*/
|
||||
size_t ksize(const void *objp)
|
||||
{
|
||||
if (unlikely(ZERO_OR_NULL_PTR(objp)))
|
||||
BUG_ON(!objp);
|
||||
if (unlikely(objp == ZERO_SIZE_PTR))
|
||||
return 0;
|
||||
|
||||
return obj_size(virt_to_cache(objp));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue