mtd: use vzalloc
authorJoe Perches <joe@perches.com>
Fri, 5 Nov 2010 03:07:40 +0000 (20:07 -0700)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Fri, 3 Dec 2010 16:27:29 +0000 (16:27 +0000)
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
drivers/mtd/nand/nandsim.c
drivers/mtd/ubi/vtbl.c

index c45e06fba15427188e20e093a05021ed00fa31c3..a5aa99f014baced88b637de9e3aa61e32e6c6925 100644 (file)
@@ -470,7 +470,7 @@ static int alloc_device(struct nandsim *ns)
                        err = -EINVAL;
                        goto err_close;
                }
-               ns->pages_written = vmalloc(ns->geom.pgnum);
+               ns->pages_written = vzalloc(ns->geom.pgnum);
                if (!ns->pages_written) {
                        NS_ERR("alloc_device: unable to allocate pages written array\n");
                        err = -ENOMEM;
@@ -483,7 +483,6 @@ static int alloc_device(struct nandsim *ns)
                        goto err_free;
                }
                ns->cfile = cfile;
-               memset(ns->pages_written, 0, ns->geom.pgnum);
                return 0;
        }
 
index fcdb7f65fe0beb3388b60daeab433733d4f1ecc7..0b8141fc5c26b388788f39b25f04ea6c4a0deba0 100644 (file)
@@ -425,12 +425,11 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi,
 
        /* Read both LEB 0 and LEB 1 into memory */
        ubi_rb_for_each_entry(rb, seb, &sv->root, u.rb) {
-               leb[seb->lnum] = vmalloc(ubi->vtbl_size);
+               leb[seb->lnum] = vzalloc(ubi->vtbl_size);
                if (!leb[seb->lnum]) {
                        err = -ENOMEM;
                        goto out_free;
                }
-               memset(leb[seb->lnum], 0, ubi->vtbl_size);
 
                err = ubi_io_read_data(ubi, leb[seb->lnum], seb->pnum, 0,
                                       ubi->vtbl_size);
@@ -516,10 +515,9 @@ static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi,
        int i;
        struct ubi_vtbl_record *vtbl;
 
-       vtbl = vmalloc(ubi->vtbl_size);
+       vtbl = vzalloc(ubi->vtbl_size);
        if (!vtbl)
                return ERR_PTR(-ENOMEM);
-       memset(vtbl, 0, ubi->vtbl_size);
 
        for (i = 0; i < ubi->vtbl_slots; i++)
                memcpy(&vtbl[i], &empty_vtbl_record, UBI_VTBL_RECORD_SIZE);