summaryrefslogtreecommitdiff
path: root/mm
diff options
context:
space:
mode:
authorCatalin Marinas <catalin.marinas@arm.com>2011-04-27 16:44:26 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2011-06-23 15:24:00 -0700
commitb2300b3b5d1294dcdb655ee34800ba8b3cfdc65d (patch)
tree4cac96d193531579af18d7741cb2f3ce44cca9c5 /mm
parent66e69865f32ed923518b80172d7c4595ce593683 (diff)
kmemleak: Do not return a pointer to an object that kmemleak did not get
commit 52c3ce4ec5601ee383a14f1485f6bac7b278896e upstream. The kmemleak_seq_next() function tries to get an object (and increment its use count) before returning it. If it could not get the last object during list traversal (because it may have been freed), the function should return NULL rather than a pointer to such object that it did not get. Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Reported-by: Phil Carmody <ext-phil.2.carmody@nokia.com> Acked-by: Phil Carmody <ext-phil.2.carmody@nokia.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'mm')
-rw-r--r--mm/kmemleak.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 8bf765c4f58d..c3466601d3e7 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -1354,9 +1354,12 @@ static void *kmemleak_seq_next(struct seq_file *seq, void *v, loff_t *pos)
++(*pos);
list_for_each_continue_rcu(n, &object_list) {
- next_obj = list_entry(n, struct kmemleak_object, object_list);
- if (get_object(next_obj))
+ struct kmemleak_object *obj =
+ list_entry(n, struct kmemleak_object, object_list);
+ if (get_object(obj)) {
+ next_obj = obj;
break;
+ }
}
put_object(prev_obj);