[PATCH 2/3] mm/kmemleak.c: Use list_for_each_entry_safe to reconstructfunction scan_gray_list

From: majianpeng
Date: Tue May 14 2013 - 07:49:56 EST


This is a multi-part message in MIME format.Signed-off-by: Jianpeng Ma <majianpeng@xxxxxxxxx>
---
mm/kmemleak.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index b1525db..f0ece93 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -1225,22 +1225,16 @@ static void scan_gray_list(void)
* from inside the loop. The kmemleak objects cannot be freed from
* outside the loop because their use_count was incremented.
*/
- object = list_entry(gray_list.next, typeof(*object), gray_list);
- while (&object->gray_list != &gray_list) {
+ list_for_each_entry_safe(object, tmp, &gray_list, gray_list) {
cond_resched();

/* may add new objects to the list */
if (!scan_should_stop())
scan_object(object);

- tmp = list_entry(object->gray_list.next, typeof(*object),
- gray_list);
-
/* remove the object from the list and release it */
list_del(&object->gray_list);
put_object(object);
-
- object = tmp;
}
WARN_ON(!list_empty(&gray_list));
}
--
1.8.3.rc1.44.gb387c77