* [PATCH] kmemleak: do not leak object after tree insertion error (v3)
@ 2012-04-18 15:44 ` Sergey Senozhatsky
0 siblings, 0 replies; 4+ messages in thread
From: Sergey Senozhatsky @ 2012-04-18 15:44 UTC (permalink / raw)
To: Catalin Marinas; +Cc: linux-mm, linux-kernel
[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.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
mm/kmemleak.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 45eb621..5f05993 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -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);
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] kmemleak: do not leak object after tree insertion error (v3)
@ 2012-04-18 15:44 ` Sergey Senozhatsky
0 siblings, 0 replies; 4+ messages in thread
From: Sergey Senozhatsky @ 2012-04-18 15:44 UTC (permalink / raw)
To: Catalin Marinas; +Cc: linux-mm, linux-kernel
[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.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
mm/kmemleak.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 45eb621..5f05993 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -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 majordomo@kvack.org. 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:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] kmemleak: do not leak object after tree insertion error (v3)
2012-04-18 15:44 ` Sergey Senozhatsky
@ 2012-04-19 9:19 ` Catalin Marinas
-1 siblings, 0 replies; 4+ messages in thread
From: Catalin Marinas @ 2012-04-19 9:19 UTC (permalink / raw)
To: Sergey Senozhatsky; +Cc: linux-mm, linux-kernel
On Wed, Apr 18, 2012 at 04:44:48PM +0100, Sergey Senozhatsky wrote:
> [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.
>
> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Thanks. I applied it to my kmemleak branch and I'll send it to Linus at
some point (during the next merging window).
--
Catalin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] kmemleak: do not leak object after tree insertion error (v3)
@ 2012-04-19 9:19 ` Catalin Marinas
0 siblings, 0 replies; 4+ messages in thread
From: Catalin Marinas @ 2012-04-19 9:19 UTC (permalink / raw)
To: Sergey Senozhatsky; +Cc: linux-mm, linux-kernel
On Wed, Apr 18, 2012 at 04:44:48PM +0100, Sergey Senozhatsky wrote:
> [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.
>
> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Thanks. I applied it to my kmemleak branch and I'll send it to Linus at
some point (during the next merging window).
--
Catalin
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. 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:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-04-19 9:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-18 15:44 [PATCH] kmemleak: do not leak object after tree insertion error (v3) Sergey Senozhatsky
2012-04-18 15:44 ` Sergey Senozhatsky
2012-04-19 9:19 ` Catalin Marinas
2012-04-19 9:19 ` Catalin Marinas
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.