mtd: rawnand: Use kzalloc() instead of kmalloc() and memset()
authorFuqian Huang <huangfq.daxian@gmail.com>
Fri, 28 Jun 2019 02:48:13 +0000 (10:48 +0800)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Fri, 28 Jun 2019 10:00:46 +0000 (12:00 +0200)
Replace kmalloc() by a memset() followed with a kzalloc().

There is a recommendation to use zeroing allocator
rather than allocator followed by memset(0) in
./scripts/coccinelle/api/alloc/zalloc-simple.cocci

Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
drivers/mtd/nand/raw/nand_bch.c

index 55aa4c1cd414a4a64ff00a8d33c8a651b5078621..17527310c3a1db8eedb0effaf6c766159af1f402 100644 (file)
@@ -170,7 +170,7 @@ struct nand_bch_control *nand_bch_init(struct mtd_info *mtd)
                goto fail;
        }
 
-       nbc->eccmask = kmalloc(eccbytes, GFP_KERNEL);
+       nbc->eccmask = kzalloc(eccbytes, GFP_KERNEL);
        nbc->errloc = kmalloc_array(t, sizeof(*nbc->errloc), GFP_KERNEL);
        if (!nbc->eccmask || !nbc->errloc)
                goto fail;
@@ -182,7 +182,6 @@ struct nand_bch_control *nand_bch_init(struct mtd_info *mtd)
                goto fail;
 
        memset(erased_page, 0xff, eccsize);
-       memset(nbc->eccmask, 0, eccbytes);
        encode_bch(nbc->bch, erased_page, eccsize, nbc->eccmask);
        kfree(erased_page);