linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/slab_common: Use kmem_cache_free
@ 2015-02-09  5:28 Vaishali Thakkar
  2015-02-09 14:53 ` Christoph Lameter
  2015-02-10 21:51 ` David Rientjes
  0 siblings, 2 replies; 3+ messages in thread
From: Vaishali Thakkar @ 2015-02-09  5:28 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: Christoph Lameter, Pekka Enberg, David Rientjes, Joonsoo Kim,
	Andrew Morton, linux-mm, linux-kernel

Here, free memory is allocated using kmem_cache_zalloc.
So, use kmem_cache_free instead of kfree.

This is done using Coccinelle and semantic patch used
is as follows:

@@
expression x,E,c;
@@

 x = \(kmem_cache_alloc\|kmem_cache_zalloc\|kmem_cache_alloc_node\)(c,...)
 ... when != x = E
     when != &x
?-kfree(x)
+kmem_cache_free(c,x)

Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com>
---
 mm/slab_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/slab_common.c b/mm/slab_common.c
index e03dd6f..67f182c 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -331,7 +331,7 @@ out:
 
 out_free_cache:
 	memcg_free_cache_params(s);
-	kfree(s);
+	kmem_cache_free(kmem_cache, s);
 	goto out;
 }
 
-- 
1.9.1

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

* Re: [PATCH] mm/slab_common: Use kmem_cache_free
  2015-02-09  5:28 [PATCH] mm/slab_common: Use kmem_cache_free Vaishali Thakkar
@ 2015-02-09 14:53 ` Christoph Lameter
  2015-02-10 21:51 ` David Rientjes
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Lameter @ 2015-02-09 14:53 UTC (permalink / raw)
  To: Vaishali Thakkar
  Cc: Stephen Rothwell, Pekka Enberg, David Rientjes, Joonsoo Kim,
	Andrew Morton, linux-mm, linux-kernel

On Mon, 9 Feb 2015, Vaishali Thakkar wrote:

> Here, free memory is allocated using kmem_cache_zalloc.
> So, use kmem_cache_free instead of kfree.

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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm/slab_common: Use kmem_cache_free
  2015-02-09  5:28 [PATCH] mm/slab_common: Use kmem_cache_free Vaishali Thakkar
  2015-02-09 14:53 ` Christoph Lameter
@ 2015-02-10 21:51 ` David Rientjes
  1 sibling, 0 replies; 3+ messages in thread
From: David Rientjes @ 2015-02-10 21:51 UTC (permalink / raw)
  To: Vaishali Thakkar
  Cc: Stephen Rothwell, Christoph Lameter, Pekka Enberg, Joonsoo Kim,
	Andrew Morton, linux-mm, linux-kernel

On Mon, 9 Feb 2015, Vaishali Thakkar wrote:

> Here, free memory is allocated using kmem_cache_zalloc.
> So, use kmem_cache_free instead of kfree.
> 
> This is done using Coccinelle and semantic patch used
> is as follows:
> 
> @@
> expression x,E,c;
> @@
> 
>  x = \(kmem_cache_alloc\|kmem_cache_zalloc\|kmem_cache_alloc_node\)(c,...)
>  ... when != x = E
>      when != &x
> ?-kfree(x)
> +kmem_cache_free(c,x)
> 
> Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com>

Acked-by: David Rientjes <rientjes@google.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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2015-02-10 21:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-09  5:28 [PATCH] mm/slab_common: Use kmem_cache_free Vaishali Thakkar
2015-02-09 14:53 ` Christoph Lameter
2015-02-10 21:51 ` David Rientjes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox