linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 14/27] mtd: nand: use kzalloc instead of kmalloc and memset
@ 2019-06-28  2:48 Fuqian Huang
  2019-06-28 18:36 ` Miquel Raynal
  0 siblings, 1 reply; 2+ messages in thread
From: Fuqian Huang @ 2019-06-28  2:48 UTC (permalink / raw)
  Cc: Fuqian Huang, Miquel Raynal, Richard Weinberger, David Woodhouse,
	Brian Norris, Marek Vasut, Vignesh Raghavendra, Boris Brezillon,
	Allison Randal, Greg Kroah-Hartman, Thomas Gleixner, linux-mtd,
	linux-kernel

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(-)

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);
 
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2 14/27] mtd: nand: use kzalloc instead of kmalloc and memset
  2019-06-28  2:48 [PATCH v2 14/27] mtd: nand: use kzalloc instead of kmalloc and memset Fuqian Huang
@ 2019-06-28 18:36 ` Miquel Raynal
  0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2019-06-28 18:36 UTC (permalink / raw)
  To: Fuqian Huang
  Cc: Miquel Raynal, Vignesh Raghavendra, Boris Brezillon,
	Richard Weinberger, Greg Kroah-Hartman, linux-kernel,
	Marek Vasut, linux-mtd, Thomas Gleixner, Brian Norris,
	David Woodhouse, Allison Randal

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-06-28 18:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-28  2:48 [PATCH v2 14/27] mtd: nand: use kzalloc instead of kmalloc and memset Fuqian Huang
2019-06-28 18:36 ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).