Skip to contentSkip to conversation

kmemleak: do not leak object after tree insertion error (v3)

PATCH In review Sergey Senozhatsky 2 participants 2 messages Apr 18, 2012 – Apr 19, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kmemleak: do not leak object after tree insertion error (v3)

[PATCH] kmemleak: do not leak object after tree insertion error

In case when tree insertion fails due to already existing object error, pointer to allocated object gets lost because of overwrite with lookup_object() return. Free allocated object before object lookup.

---

 mm/kmemleak.c |    1 +
 1 file changed, 1 insertion(+)
mm/kmemleak.c +1 -0
index 45eb621..5f05993 100644
@@ -578,6 +578,7 @@ static struct kmemleak_object *create_object(unsigned long ptr, size_t size,
 	if (node != &object->tree_node) {
 		kmemleak_stop("Cannot insert 0x%lx into the object search tree "
 			      "(already existing)\n", ptr);
+		kmem_cache_free(object_cache, object);
 		object = lookup_object(ptr, 1);
 		spin_lock(&object->lock);
 		dump_object_info(object);

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

maintainer
#1 lore raw
Quoted 8 lines · Sergey Senozhatsky

[PATCH] kmemleak: do not leak object after tree insertion error

In case when tree insertion fails due to already existing object error, pointer to allocated object gets lost because of overwrite with lookup_object() return. Free allocated object before object lookup.

Thanks. I applied it to my kmemleak branch and I'll send it to Linus at some point (during the next merging window).

Signature · 8 lines
Catalin

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>