kmemleak: Release the object lock before calling put_object()
authorCatalin Marinas <catalin.marinas@arm.com>
Wed, 28 Oct 2009 13:33:11 +0000 (13:33 +0000)
committerCatalin Marinas <catalin.marinas@arm.com>
Wed, 28 Oct 2009 17:07:54 +0000 (17:07 +0000)
The put_object() function may free the object if the use_count
dropped to 0. There shouldn't be further accesses to such object unless
it is known that the use_count is non-zero.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
mm/kmemleak.c

index 96106358e04282b8baf91440f582eee71f51d4bd..f06c0921e4721646669d1bcc5d78574949fb3bfd 100644 (file)
@@ -1025,11 +1025,14 @@ static void scan_block(void *_start, void *_end,
                 * added to the gray_list.
                 */
                object->count++;
-               if (color_gray(object))
+               if (color_gray(object)) {
                        list_add_tail(&object->gray_list, &gray_list);
-               else
-                       put_object(object);
+                       spin_unlock_irqrestore(&object->lock, flags);
+                       continue;
+               }
+
                spin_unlock_irqrestore(&object->lock, flags);
+               put_object(object);
        }
 }