Skip to content

Commit

Permalink
fs/ocfs2/dlm/dlmlock.c: free kmem_cache_zalloc'd data using kmem_cach…
Browse files Browse the repository at this point in the history
…e_free

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>
Signed-off-by: Joel Becker <jlbec@evilplan.org>
  • Loading branch information
Julia Lawall authored and Joel Becker committed Nov 17, 2011
1 parent 99b1bb6 commit fc9f899
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/ocfs2/dlm/dlmlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ struct dlm_lock * dlm_new_lock(int type, u8 node, u64 cookie,
/* 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;
Expand Down

0 comments on commit fc9f899

Please sign in to comment.