aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2012-05-15 04:58:12 -0400
committerDavid Teigland <teigland@redhat.com>2012-05-15 11:39:28 -0400
commit75af271ed5f51b1f3506c7c1d567b1f32e5c9206 (patch)
tree5df97190f3ac4aba1bfed021e1a03392d447830e /fs
parent1a058f5288a74a20d5567a85ab1a04a9de69a212 (diff)
dlm: NULL dereference on failure in kmem_cache_create()
We aren't allowed to pass NULL pointers to kmem_cache_destroy() so if both allocations fail, it leads to a NULL dereference. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: David Teigland <teigland@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/dlm/memory.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/fs/dlm/memory.c b/fs/dlm/memory.c
index da64df7576e1..7cd24bccd4fe 100644
--- a/fs/dlm/memory.c
+++ b/fs/dlm/memory.c
@@ -21,21 +21,19 @@ static struct kmem_cache *rsb_cache;
21 21
22int __init dlm_memory_init(void) 22int __init dlm_memory_init(void)
23{ 23{
24 int ret = 0;
25
26 lkb_cache = kmem_cache_create("dlm_lkb", sizeof(struct dlm_lkb), 24 lkb_cache = kmem_cache_create("dlm_lkb", sizeof(struct dlm_lkb),
27 __alignof__(struct dlm_lkb), 0, NULL); 25 __alignof__(struct dlm_lkb), 0, NULL);
28 if (!lkb_cache) 26 if (!lkb_cache)
29 ret = -ENOMEM; 27 return -ENOMEM;
30 28
31 rsb_cache = kmem_cache_create("dlm_rsb", sizeof(struct dlm_rsb), 29 rsb_cache = kmem_cache_create("dlm_rsb", sizeof(struct dlm_rsb),
32 __alignof__(struct dlm_rsb), 0, NULL); 30 __alignof__(struct dlm_rsb), 0, NULL);
33 if (!rsb_cache) { 31 if (!rsb_cache) {
34 kmem_cache_destroy(lkb_cache); 32 kmem_cache_destroy(lkb_cache);
35 ret = -ENOMEM; 33 return -ENOMEM;
36 } 34 }
37 35
38 return ret; 36 return 0;
39} 37}
40 38
41void dlm_memory_exit(void) 39void dlm_memory_exit(void)