]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/dlm/memory.c
USB: image: mdc800: clean up urb->status usage
[linux-2.6-omap-h63xx.git] / fs / dlm / memory.c
index f7cf4589fae8fca03d5d5afeeedb4e26328b9fb8..fb9e2ee998ae1c9feccc509473f6aa56823759ec 100644 (file)
@@ -15,7 +15,7 @@
 #include "config.h"
 #include "memory.h"
 
-static kmem_cache_t *lkb_cache;
+static struct kmem_cache *lkb_cache;
 
 
 int dlm_memory_init(void)
@@ -39,9 +39,7 @@ char *allocate_lvb(struct dlm_ls *ls)
 {
        char *p;
 
-       p = kmalloc(ls->ls_lvblen, GFP_KERNEL);
-       if (p)
-               memset(p, 0, ls->ls_lvblen);
+       p = kzalloc(ls->ls_lvblen, GFP_KERNEL);
        return p;
 }
 
@@ -59,9 +57,7 @@ struct dlm_rsb *allocate_rsb(struct dlm_ls *ls, int namelen)
 
        DLM_ASSERT(namelen <= DLM_RESNAME_MAXLEN,);
 
-       r = kmalloc(sizeof(*r) + namelen, GFP_KERNEL);
-       if (r)
-               memset(r, 0, sizeof(*r) + namelen);
+       r = kzalloc(sizeof(*r) + namelen, GFP_KERNEL);
        return r;
 }
 
@@ -76,14 +72,21 @@ struct dlm_lkb *allocate_lkb(struct dlm_ls *ls)
 {
        struct dlm_lkb *lkb;
 
-       lkb = kmem_cache_alloc(lkb_cache, GFP_KERNEL);
-       if (lkb)
-               memset(lkb, 0, sizeof(*lkb));
+       lkb = kmem_cache_zalloc(lkb_cache, GFP_KERNEL);
        return lkb;
 }
 
 void free_lkb(struct dlm_lkb *lkb)
 {
+       if (lkb->lkb_flags & DLM_IFL_USER) {
+               struct dlm_user_args *ua;
+               ua = (struct dlm_user_args *)lkb->lkb_astparam;
+               if (ua) {
+                       if (ua->lksb.sb_lvbptr)
+                               kfree(ua->lksb.sb_lvbptr);
+                       kfree(ua);
+               }
+       }
        kmem_cache_free(lkb_cache, lkb);
 }
 
@@ -91,11 +94,10 @@ struct dlm_direntry *allocate_direntry(struct dlm_ls *ls, int namelen)
 {
        struct dlm_direntry *de;
 
-       DLM_ASSERT(namelen <= DLM_RESNAME_MAXLEN,);
+       DLM_ASSERT(namelen <= DLM_RESNAME_MAXLEN,
+                  printk("namelen = %d\n", namelen););
 
-       de = kmalloc(sizeof(*de) + namelen, GFP_KERNEL);
-       if (de)
-               memset(de, 0, sizeof(*de) + namelen);
+       de = kzalloc(sizeof(*de) + namelen, GFP_KERNEL);
        return de;
 }