kmemleak: Check for NULL pointer returned by create_object()
authorCatalin Marinas <catalin.marinas@arm.com>
Fri, 9 Oct 2009 09:30:34 +0000 (10:30 +0100)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 9 Oct 2009 20:28:47 +0000 (13:28 -0700)
This patch adds NULL pointer checking in the early_alloc() function.

Reported-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/kmemleak.c

index a6175180d18817841ca49f139a878ce9d6916a4a..8bf765c4f58d03922adf1f7a100679fe05c65d7d 100644 (file)
@@ -834,11 +834,14 @@ static void early_alloc(struct early_log *log)
        rcu_read_lock();
        object = create_object((unsigned long)log->ptr, log->size,
                               log->min_count, GFP_ATOMIC);
+       if (!object)
+               goto out;
        spin_lock_irqsave(&object->lock, flags);
        for (i = 0; i < log->trace_len; i++)
                object->trace[i] = log->trace[i];
        object->trace_len = log->trace_len;
        spin_unlock_irqrestore(&object->lock, flags);
+out:
        rcu_read_unlock();
 }