]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - fs/ubifs/lpt.c
treewide: Use array_size() in vmalloc()
[linux.git] / fs / ubifs / lpt.c
index 9a517109da0feda2ac19ba4781072ab4ab4aad31..8e99dad1888009f764d49ffc359be3a3b23578a3 100644 (file)
@@ -628,11 +628,12 @@ int ubifs_create_dflt_lpt(struct ubifs_info *c, int *main_lebs, int lpt_first,
        /* Needed by 'ubifs_pack_lsave()' */
        c->main_first = c->leb_cnt - *main_lebs;
 
-       lsave = kmalloc(sizeof(int) * c->lsave_cnt, GFP_KERNEL);
+       lsave = kmalloc_array(c->lsave_cnt, sizeof(int), GFP_KERNEL);
        pnode = kzalloc(sizeof(struct ubifs_pnode), GFP_KERNEL);
        nnode = kzalloc(sizeof(struct ubifs_nnode), GFP_KERNEL);
        buf = vmalloc(c->leb_size);
-       ltab = vmalloc(sizeof(struct ubifs_lpt_lprops) * c->lpt_lebs);
+       ltab = vmalloc(array_size(sizeof(struct ubifs_lpt_lprops),
+                                 c->lpt_lebs));
        if (!pnode || !nnode || !buf || !ltab || !lsave) {
                err = -ENOMEM;
                goto out;
@@ -1626,7 +1627,8 @@ static int lpt_init_rd(struct ubifs_info *c)
 {
        int err, i;
 
-       c->ltab = vmalloc(sizeof(struct ubifs_lpt_lprops) * c->lpt_lebs);
+       c->ltab = vmalloc(array_size(sizeof(struct ubifs_lpt_lprops),
+                                    c->lpt_lebs));
        if (!c->ltab)
                return -ENOMEM;
 
@@ -1636,15 +1638,17 @@ static int lpt_init_rd(struct ubifs_info *c)
                return -ENOMEM;
 
        for (i = 0; i < LPROPS_HEAP_CNT; i++) {
-               c->lpt_heap[i].arr = kmalloc(sizeof(void *) * LPT_HEAP_SZ,
-                                            GFP_KERNEL);
+               c->lpt_heap[i].arr = kmalloc_array(LPT_HEAP_SZ,
+                                                  sizeof(void *),
+                                                  GFP_KERNEL);
                if (!c->lpt_heap[i].arr)
                        return -ENOMEM;
                c->lpt_heap[i].cnt = 0;
                c->lpt_heap[i].max_cnt = LPT_HEAP_SZ;
        }
 
-       c->dirty_idx.arr = kmalloc(sizeof(void *) * LPT_HEAP_SZ, GFP_KERNEL);
+       c->dirty_idx.arr = kmalloc_array(LPT_HEAP_SZ, sizeof(void *),
+                                        GFP_KERNEL);
        if (!c->dirty_idx.arr)
                return -ENOMEM;
        c->dirty_idx.cnt = 0;
@@ -1688,7 +1692,8 @@ static int lpt_init_wr(struct ubifs_info *c)
 {
        int err, i;
 
-       c->ltab_cmt = vmalloc(sizeof(struct ubifs_lpt_lprops) * c->lpt_lebs);
+       c->ltab_cmt = vmalloc(array_size(sizeof(struct ubifs_lpt_lprops),
+                                        c->lpt_lebs));
        if (!c->ltab_cmt)
                return -ENOMEM;
 
@@ -1697,7 +1702,7 @@ static int lpt_init_wr(struct ubifs_info *c)
                return -ENOMEM;
 
        if (c->big_lpt) {
-               c->lsave = kmalloc(sizeof(int) * c->lsave_cnt, GFP_NOFS);
+               c->lsave = kmalloc_array(c->lsave_cnt, sizeof(int), GFP_NOFS);
                if (!c->lsave)
                        return -ENOMEM;
                err = read_lsave(c);
@@ -1939,8 +1944,8 @@ int ubifs_lpt_scan_nolock(struct ubifs_info *c, int start_lnum, int end_lnum,
                        return err;
        }
 
-       path = kmalloc(sizeof(struct lpt_scan_node) * (c->lpt_hght + 1),
-                      GFP_NOFS);
+       path = kmalloc_array(c->lpt_hght + 1, sizeof(struct lpt_scan_node),
+                            GFP_NOFS);
        if (!path)
                return -ENOMEM;