The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] rbd: Use kmem_cache_free
@ 2014-07-22 18:11 Himangi Saraogi
  2014-07-22 18:32 ` Ilya Dryomov
  0 siblings, 1 reply; 2+ messages in thread
From: Himangi Saraogi @ 2014-07-22 18:11 UTC (permalink / raw)
  To: Yehuda Sadeh, Sage Weil, Alex Elder, ceph-devel, linux-kernel
  Cc: Julia Lawall

Free memory allocated using kmem_cache_zalloc using kmem_cache_free
rather than kfree.

The Coccinelle semantic patch that makes this change is as follows:

// <smpl>
@@
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)
// </smpl>

Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
---
 drivers/block/rbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index b2c98c1..8381c54 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1158,7 +1158,7 @@ static const char *rbd_segment_name(struct rbd_device *rbd_dev, u64 offset)
 	if (ret < 0 || ret > CEPH_MAX_OID_NAME_LEN) {
 		pr_err("error formatting segment name for #%llu (%d)\n",
 			segment, ret);
-		kfree(name);
+		kmem_cache_free(rbd_segment_name_cache, name);
 		name = NULL;
 	}
 
-- 
1.9.1


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

* Re: [PATCH] rbd: Use kmem_cache_free
  2014-07-22 18:11 [PATCH] rbd: Use kmem_cache_free Himangi Saraogi
@ 2014-07-22 18:32 ` Ilya Dryomov
  0 siblings, 0 replies; 2+ messages in thread
From: Ilya Dryomov @ 2014-07-22 18:32 UTC (permalink / raw)
  To: Himangi Saraogi
  Cc: Alex Elder, Ceph Development, Linux Kernel Mailing List,
	Julia Lawall

On Tue, Jul 22, 2014 at 10:11 PM, Himangi Saraogi <himangi774@gmail.com> wrote:
> Free memory allocated using kmem_cache_zalloc using kmem_cache_free
> rather than kfree.
>
> The Coccinelle semantic patch that makes this change is as follows:
>
> // <smpl>
> @@
> 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)
> // </smpl>
>
> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> Acked-by: Julia Lawall <julia.lawall@lip6.fr>
> ---
>  drivers/block/rbd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index b2c98c1..8381c54 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -1158,7 +1158,7 @@ static const char *rbd_segment_name(struct rbd_device *rbd_dev, u64 offset)
>         if (ret < 0 || ret > CEPH_MAX_OID_NAME_LEN) {
>                 pr_err("error formatting segment name for #%llu (%d)\n",
>                         segment, ret);
> -               kfree(name);
> +               kmem_cache_free(rbd_segment_name_cache, name);
>                 name = NULL;
>         }

We seem to have a helper for this, rbd_segment_name_free().  Care to
resend?

Thanks,

                Ilya

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

end of thread, other threads:[~2014-07-22 18:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-22 18:11 [PATCH] rbd: Use kmem_cache_free Himangi Saraogi
2014-07-22 18:32 ` Ilya Dryomov

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