Skip to content
Snippets Groups Projects
Commit b2300b3b authored by Catalin Marinas's avatar Catalin Marinas Committed by Greg Kroah-Hartman
Browse files

kmemleak: Do not return a pointer to an object that kmemleak did not get


commit 52c3ce4e 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: default avatarCatalin Marinas <catalin.marinas@arm.com>
Reported-by: default avatarPhil Carmody <ext-phil.2.carmody@nokia.com>
Acked-by: default avatarPhil Carmody <ext-phil.2.carmody@nokia.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 66e69865
No related branches found
No related tags found
No related merge requests found
...@@ -1354,9 +1354,12 @@ static void *kmemleak_seq_next(struct seq_file *seq, void *v, loff_t *pos) ...@@ -1354,9 +1354,12 @@ static void *kmemleak_seq_next(struct seq_file *seq, void *v, loff_t *pos)
++(*pos); ++(*pos);
list_for_each_continue_rcu(n, &object_list) { list_for_each_continue_rcu(n, &object_list) {
next_obj = list_entry(n, struct kmemleak_object, object_list); struct kmemleak_object *obj =
if (get_object(next_obj)) list_entry(n, struct kmemleak_object, object_list);
if (get_object(obj)) {
next_obj = obj;
break; break;
}
} }
put_object(prev_obj); put_object(prev_obj);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment