All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] slub: fix a possible memory leak
@ 2012-05-10 15:32 ` Joonsoo Kim
  0 siblings, 0 replies; 8+ messages in thread
From: Joonsoo Kim @ 2012-05-10 15:32 UTC (permalink / raw)
  To: Pekka Enberg; +Cc: Christoph Lameter, linux-kernel, linux-mm, Joonsoo Kim

Memory allocated by kstrdup should be freed,
when kmalloc(kmem_size, GFP_KERNEL) is failed.

Signed-off-by: Joonsoo Kim <js1304@gmail.com>

diff --git a/mm/slub.c b/mm/slub.c
index 23d66aa..9c920a0 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3968,9 +3968,9 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size,
 			}
 			return s;
 		}
-		kfree(n);
 		kfree(s);
 	}
+	kfree(n);
 err:
 	up_write(&slub_lock);
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] slub: fix a possible memory leak
@ 2012-05-10 15:32 ` Joonsoo Kim
  0 siblings, 0 replies; 8+ messages in thread
From: Joonsoo Kim @ 2012-05-10 15:32 UTC (permalink / raw)
  To: Pekka Enberg; +Cc: Christoph Lameter, linux-kernel, linux-mm, Joonsoo Kim

Memory allocated by kstrdup should be freed,
when kmalloc(kmem_size, GFP_KERNEL) is failed.

Signed-off-by: Joonsoo Kim <js1304@gmail.com>

diff --git a/mm/slub.c b/mm/slub.c
index 23d66aa..9c920a0 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3968,9 +3968,9 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size,
 			}
 			return s;
 		}
-		kfree(n);
 		kfree(s);
 	}
+	kfree(n);
 err:
 	up_write(&slub_lock);
 
-- 
1.7.9.5

--
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] 8+ messages in thread

* Re: [PATCH] slub: fix a possible memory leak
  2012-05-10 15:32 ` Joonsoo Kim
@ 2012-05-10 15:41   ` Christoph Lameter
  -1 siblings, 0 replies; 8+ messages in thread
From: Christoph Lameter @ 2012-05-10 15:41 UTC (permalink / raw)
  To: Joonsoo Kim; +Cc: Pekka Enberg, linux-kernel, linux-mm

On Fri, 11 May 2012, Joonsoo Kim wrote:

> Memory allocated by kstrdup should be freed,
> when kmalloc(kmem_size, GFP_KERNEL) is failed.

True.

Acked-by: Christoph Lameter <cl@linux.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] slub: fix a possible memory leak
@ 2012-05-10 15:41   ` Christoph Lameter
  0 siblings, 0 replies; 8+ messages in thread
From: Christoph Lameter @ 2012-05-10 15:41 UTC (permalink / raw)
  To: Joonsoo Kim; +Cc: Pekka Enberg, linux-kernel, linux-mm

On Fri, 11 May 2012, Joonsoo Kim wrote:

> Memory allocated by kstrdup should be freed,
> when kmalloc(kmem_size, GFP_KERNEL) is failed.

True.

Acked-by: Christoph Lameter <cl@linux.com>

--
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] 8+ messages in thread

* Re: [PATCH] slub: fix a possible memory leak
  2012-05-10 15:32 ` Joonsoo Kim
@ 2012-05-15  6:28   ` David Rientjes
  -1 siblings, 0 replies; 8+ messages in thread
From: David Rientjes @ 2012-05-15  6:28 UTC (permalink / raw)
  To: Joonsoo Kim; +Cc: Pekka Enberg, Christoph Lameter, linux-kernel, linux-mm

On Fri, 11 May 2012, Joonsoo Kim wrote:

> Memory allocated by kstrdup should be freed,
> when kmalloc(kmem_size, GFP_KERNEL) is failed.
> 
> Signed-off-by: Joonsoo Kim <js1304@gmail.com>

Acked-by: David Rientjes <rientjes@google.com>

kmem_cache_create() in slub would significantly be improved with a rewrite 
to have a clear error path and use of return values of functions it calls.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] slub: fix a possible memory leak
@ 2012-05-15  6:28   ` David Rientjes
  0 siblings, 0 replies; 8+ messages in thread
From: David Rientjes @ 2012-05-15  6:28 UTC (permalink / raw)
  To: Joonsoo Kim; +Cc: Pekka Enberg, Christoph Lameter, linux-kernel, linux-mm

On Fri, 11 May 2012, Joonsoo Kim wrote:

> Memory allocated by kstrdup should be freed,
> when kmalloc(kmem_size, GFP_KERNEL) is failed.
> 
> Signed-off-by: Joonsoo Kim <js1304@gmail.com>

Acked-by: David Rientjes <rientjes@google.com>

kmem_cache_create() in slub would significantly be improved with a rewrite 
to have a clear error path and use of return values of functions it calls.

--
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] 8+ messages in thread

* Re: [PATCH] slub: fix a possible memory leak
  2012-05-15  6:28   ` David Rientjes
@ 2012-05-16  6:37     ` Pekka Enberg
  -1 siblings, 0 replies; 8+ messages in thread
From: Pekka Enberg @ 2012-05-16  6:37 UTC (permalink / raw)
  To: David Rientjes; +Cc: Joonsoo Kim, Christoph Lameter, linux-kernel, linux-mm

On Tue, May 15, 2012 at 9:28 AM, David Rientjes <rientjes@google.com> wrote:
> On Fri, 11 May 2012, Joonsoo Kim wrote:
>
>> Memory allocated by kstrdup should be freed,
>> when kmalloc(kmem_size, GFP_KERNEL) is failed.
>>
>> Signed-off-by: Joonsoo Kim <js1304@gmail.com>
>
> Acked-by: David Rientjes <rientjes@google.com>
>
> kmem_cache_create() in slub would significantly be improved with a rewrite
> to have a clear error path and use of return values of functions it calls.

Applied, thanks!

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] slub: fix a possible memory leak
@ 2012-05-16  6:37     ` Pekka Enberg
  0 siblings, 0 replies; 8+ messages in thread
From: Pekka Enberg @ 2012-05-16  6:37 UTC (permalink / raw)
  To: David Rientjes; +Cc: Joonsoo Kim, Christoph Lameter, linux-kernel, linux-mm

On Tue, May 15, 2012 at 9:28 AM, David Rientjes <rientjes@google.com> wrote:
> On Fri, 11 May 2012, Joonsoo Kim wrote:
>
>> Memory allocated by kstrdup should be freed,
>> when kmalloc(kmem_size, GFP_KERNEL) is failed.
>>
>> Signed-off-by: Joonsoo Kim <js1304@gmail.com>
>
> Acked-by: David Rientjes <rientjes@google.com>
>
> kmem_cache_create() in slub would significantly be improved with a rewrite
> to have a clear error path and use of return values of functions it calls.

Applied, thanks!

--
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] 8+ messages in thread

end of thread, other threads:[~2012-05-16  6:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-10 15:32 [PATCH] slub: fix a possible memory leak Joonsoo Kim
2012-05-10 15:32 ` Joonsoo Kim
2012-05-10 15:41 ` Christoph Lameter
2012-05-10 15:41   ` Christoph Lameter
2012-05-15  6:28 ` David Rientjes
2012-05-15  6:28   ` David Rientjes
2012-05-16  6:37   ` Pekka Enberg
2012-05-16  6:37     ` Pekka Enberg

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.