diff mbox series

[v2,14/27] mtd: nand: use kzalloc instead of kmalloc and memset

Message ID 20190628024814.15527-1-huangfq.daxian@gmail.com
State Accepted
Headers show
Series None | expand

Commit Message

Fuqian Huang June 28, 2019, 2:48 a.m. UTC
Replace kmalloc followed by a memset with kzalloc.

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

Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com>
---
 drivers/mtd/nand/raw/nand_bch.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Miquel Raynal June 28, 2019, 6:36 p.m. UTC | #1
On Fri, 2019-06-28 at 02:48:13 UTC, Fuqian Huang wrote:
> Replace kmalloc followed by a memset with kzalloc.
> 
> There is a recommendation to use zeroing allocator
> rather than allocator followed by memset with 0 in
> ./scripts/coccinelle/api/alloc/zalloc-simple.cocci
> 
> Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next, thanks.

Miquel
diff mbox series

Patch

diff --git a/drivers/mtd/nand/raw/nand_bch.c b/drivers/mtd/nand/raw/nand_bch.c
index 55aa4c1cd414..17527310c3a1 100644
--- a/drivers/mtd/nand/raw/nand_bch.c
+++ b/drivers/mtd/nand/raw/nand_bch.c
@@ -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);