* [PATCH] fs/ocfs2/dlm/dlmlock.c: free kmem_cache_zalloc'd data using kmem_cache_free
@ 2011-07-09 16:04 Julia Lawall
2011-07-09 18:33 ` Pekka Enberg
2011-08-22 4:28 ` Joel Becker
0 siblings, 2 replies; 3+ messages in thread
From: Julia Lawall @ 2011-07-09 16:04 UTC (permalink / raw)
To: Mark Fasheh
Cc: kernel-janitors, Joel Becker, Wengang Wang, Tao Ma, ocfs2-devel,
linux-kernel
From: Julia Lawall <julia@diku.dk>
Memory allocated using kmem_cache_zalloc should be freed using
kmem_cache_free, not kfree.
The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression x,e,e1,e2;
@@
x = kmem_cache_zalloc(e1,e2)
... when != x = e
?-kfree(x)
+kmem_cache_free(e1,x)
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
---
fs/ocfs2/dlm/dlmlock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff -u -p a/fs/ocfs2/dlm/dlmlock.c b/fs/ocfs2/dlm/dlmlock.c
--- a/fs/ocfs2/dlm/dlmlock.c
+++ b/fs/ocfs2/dlm/dlmlock.c
@@ -440,7 +440,7 @@ struct dlm_lock * dlm_new_lock(int type,
/* zero memory only if kernel-allocated */
lksb = kzalloc(sizeof(*lksb), GFP_NOFS);
if (!lksb) {
- kfree(lock);
+ kmem_cache_free(dlm_lock_cache, lock);
return NULL;
}
kernel_allocated = 1;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fs/ocfs2/dlm/dlmlock.c: free kmem_cache_zalloc'd data using kmem_cache_free
2011-07-09 16:04 [PATCH] fs/ocfs2/dlm/dlmlock.c: free kmem_cache_zalloc'd data using kmem_cache_free Julia Lawall
@ 2011-07-09 18:33 ` Pekka Enberg
2011-08-22 4:28 ` Joel Becker
1 sibling, 0 replies; 3+ messages in thread
From: Pekka Enberg @ 2011-07-09 18:33 UTC (permalink / raw)
To: Julia Lawall
Cc: Mark Fasheh, kernel-janitors, Joel Becker, Wengang Wang, Tao Ma,
ocfs2-devel, linux-kernel
On Sat, Jul 9, 2011 at 7:04 PM, Julia Lawall <julia@diku.dk> wrote:
> From: Julia Lawall <julia@diku.dk>
>
> Memory allocated using kmem_cache_zalloc should be freed using
> kmem_cache_free, not kfree.
>
> The semantic patch that fixes this problem is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> expression x,e,e1,e2;
> @@
>
> x = kmem_cache_zalloc(e1,e2)
> ... when != x = e
> ?-kfree(x)
> +kmem_cache_free(e1,x)
> // </smpl>
>
> Signed-off-by: Julia Lawall <julia@diku.dk>
Reviewed-by: Pekka Enberg <penberg@kernel.org>
> ---
> fs/ocfs2/dlm/dlmlock.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff -u -p a/fs/ocfs2/dlm/dlmlock.c b/fs/ocfs2/dlm/dlmlock.c
> --- a/fs/ocfs2/dlm/dlmlock.c
> +++ b/fs/ocfs2/dlm/dlmlock.c
> @@ -440,7 +440,7 @@ struct dlm_lock * dlm_new_lock(int type,
> /* zero memory only if kernel-allocated */
> lksb = kzalloc(sizeof(*lksb), GFP_NOFS);
> if (!lksb) {
> - kfree(lock);
> + kmem_cache_free(dlm_lock_cache, lock);
> return NULL;
> }
> kernel_allocated = 1;
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fs/ocfs2/dlm/dlmlock.c: free kmem_cache_zalloc'd data using kmem_cache_free
2011-07-09 16:04 [PATCH] fs/ocfs2/dlm/dlmlock.c: free kmem_cache_zalloc'd data using kmem_cache_free Julia Lawall
2011-07-09 18:33 ` Pekka Enberg
@ 2011-08-22 4:28 ` Joel Becker
1 sibling, 0 replies; 3+ messages in thread
From: Joel Becker @ 2011-08-22 4:28 UTC (permalink / raw)
To: Julia Lawall
Cc: Mark Fasheh, kernel-janitors, Wengang Wang, Tao Ma, ocfs2-devel,
linux-kernel
this patch is now in the fixes branch of ocfs2.git.
On Sat, Jul 09, 2011 at 06:04:39PM +0200, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
>
> Memory allocated using kmem_cache_zalloc should be freed using
> kmem_cache_free, not kfree.
>
> The semantic patch that fixes this problem is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> expression x,e,e1,e2;
> @@
>
> x = kmem_cache_zalloc(e1,e2)
> ... when != x = e
> ?-kfree(x)
> +kmem_cache_free(e1,x)
> // </smpl>
>
> Signed-off-by: Julia Lawall <julia@diku.dk>
>
> ---
> fs/ocfs2/dlm/dlmlock.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff -u -p a/fs/ocfs2/dlm/dlmlock.c b/fs/ocfs2/dlm/dlmlock.c
> --- a/fs/ocfs2/dlm/dlmlock.c
> +++ b/fs/ocfs2/dlm/dlmlock.c
> @@ -440,7 +440,7 @@ struct dlm_lock * dlm_new_lock(int type,
> /* zero memory only if kernel-allocated */
> lksb = kzalloc(sizeof(*lksb), GFP_NOFS);
> if (!lksb) {
> - kfree(lock);
> + kmem_cache_free(dlm_lock_cache, lock);
> return NULL;
> }
> kernel_allocated = 1;
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
Life's Little Instruction Book #43
"Never give up on somebody. Miracles happen every day."
http://www.jlbec.org/
jlbec@evilplan.org
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-08-22 4:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-09 16:04 [PATCH] fs/ocfs2/dlm/dlmlock.c: free kmem_cache_zalloc'd data using kmem_cache_free Julia Lawall
2011-07-09 18:33 ` Pekka Enberg
2011-08-22 4:28 ` Joel Becker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox