Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ef8b4520bd9f8294ffce9abd6158085bde5dc902
Commit:     ef8b4520bd9f8294ffce9abd6158085bde5dc902
Parent:     0da7e01f5f37f441cccd7c8c0586e06db0981907
Author:     Christoph Lameter <[EMAIL PROTECTED]>
AuthorDate: Tue Oct 16 01:24:46 2007 -0700
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Tue Oct 16 09:42:53 2007 -0700

    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]>
---
 mm/slab.c |    3 ++-
 mm/slob.c |    3 ++-
 mm/slub.c |    3 ++-
 mm/util.c |    6 ++++--
 4 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/mm/slab.c b/mm/slab.c
index 6f6abef..1b240a3 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -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));
diff --git a/mm/slob.c b/mm/slob.c
index a886e83..de5d556 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -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);
diff --git a/mm/slub.c b/mm/slub.c
index b7d3664..d7c044d 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2449,7 +2449,8 @@ size_t ksize(const void *object)
        struct page *page;
        struct kmem_cache *s;
 
-       if (unlikely(ZERO_OR_NULL_PTR(object)))
+       BUG_ON(!object);
+       if (unlikely(object == ZERO_SIZE_PTR))
                return 0;
 
        page = get_object_page(object);
diff --git a/mm/util.c b/mm/util.c
index bf340d8..5f64026 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -81,14 +81,16 @@ EXPORT_SYMBOL(kmemdup);
 void *krealloc(const void *p, size_t new_size, gfp_t flags)
 {
        void *ret;
-       size_t ks;
+       size_t ks = 0;
 
        if (unlikely(!new_size)) {
                kfree(p);
                return ZERO_SIZE_PTR;
        }
 
-       ks = ksize(p);
+       if (p)
+               ks = ksize(p);
+
        if (ks >= new_size)
                return (void *)p;
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to