Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 17c929e1 authored by Fuqian Huang's avatar Fuqian Huang Committed by Miquel Raynal
Browse files

mtd: rawnand: Use kzalloc() instead of kmalloc() and memset()



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: default avatarFuqian Huang <huangfq.daxian@gmail.com>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
parent b83408b5
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -170,7 +170,7 @@ struct nand_bch_control *nand_bch_init(struct mtd_info *mtd)
		goto fail;
		goto fail;
	}
	}


	nbc->eccmask = kmalloc(eccbytes, GFP_KERNEL);
	nbc->eccmask = kzalloc(eccbytes, GFP_KERNEL);
	nbc->errloc = kmalloc_array(t, sizeof(*nbc->errloc), GFP_KERNEL);
	nbc->errloc = kmalloc_array(t, sizeof(*nbc->errloc), GFP_KERNEL);
	if (!nbc->eccmask || !nbc->errloc)
	if (!nbc->eccmask || !nbc->errloc)
		goto fail;
		goto fail;
@@ -182,7 +182,6 @@ struct nand_bch_control *nand_bch_init(struct mtd_info *mtd)
		goto fail;
		goto fail;


	memset(erased_page, 0xff, eccsize);
	memset(erased_page, 0xff, eccsize);
	memset(nbc->eccmask, 0, eccbytes);
	encode_bch(nbc->bch, erased_page, eccsize, nbc->eccmask);
	encode_bch(nbc->bch, erased_page, eccsize, nbc->eccmask);
	kfree(erased_page);
	kfree(erased_page);