linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] mtd: rawnand: nandsim: Replace overflow check with kzalloc to single kcalloc
@ 2021-12-25 10:06 s921975628
  2021-12-25 21:09 ` Richard Weinberger
  2022-01-23 15:43 ` Miquel Raynal
  0 siblings, 2 replies; 3+ messages in thread
From: s921975628 @ 2021-12-25 10:06 UTC (permalink / raw)
  To: richard, vigneshr, miquel.raynal; +Cc: linux-mtd, linux-kernel, RinHizakura

From: RinHizakura <s921975628@gmail.com>

Instead of self-checking overflow and allocating an array of specific size
by counting the total required space handy, we already have existed kernel
API which responses for all these works.

Signed-off-by: RinHizakura <s921975628@gmail.com>
---
 drivers/mtd/nand/raw/nandsim.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/mtd/nand/raw/nandsim.c b/drivers/mtd/nand/raw/nandsim.c
index 0750121ac..3698fb430 100644
--- a/drivers/mtd/nand/raw/nandsim.c
+++ b/drivers/mtd/nand/raw/nandsim.c
@@ -979,15 +979,8 @@ static int ns_read_error(unsigned int page_no)
 
 static int ns_setup_wear_reporting(struct mtd_info *mtd)
 {
-	size_t mem;
-
 	wear_eb_count = div_u64(mtd->size, mtd->erasesize);
-	mem = wear_eb_count * sizeof(unsigned long);
-	if (mem / sizeof(unsigned long) != wear_eb_count) {
-		NS_ERR("Too many erase blocks for wear reporting\n");
-		return -ENOMEM;
-	}
-	erase_block_wear = kzalloc(mem, GFP_KERNEL);
+	erase_block_wear = kcalloc(wear_eb_count, sizeof(unsigned long), GFP_KERNEL);
 	if (!erase_block_wear) {
 		NS_ERR("Too many erase blocks for wear reporting\n");
 		return -ENOMEM;
-- 
2.25.1


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

* Re: [PATCH 1/3] mtd: rawnand: nandsim: Replace overflow check with kzalloc to single kcalloc
  2021-12-25 10:06 [PATCH 1/3] mtd: rawnand: nandsim: Replace overflow check with kzalloc to single kcalloc s921975628
@ 2021-12-25 21:09 ` Richard Weinberger
  2022-01-23 15:43 ` Miquel Raynal
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Weinberger @ 2021-12-25 21:09 UTC (permalink / raw)
  To: s921975628; +Cc: Vignesh Raghavendra, Miquel Raynal, linux-mtd, linux-kernel

----- Ursprüngliche Mail -----
> Von: s921975628@gmail.com
> An: "richard" <richard@nod.at>, "Vignesh Raghavendra" <vigneshr@ti.com>, "Miquel Raynal" <miquel.raynal@bootlin.com>
> CC: "linux-mtd" <linux-mtd@lists.infradead.org>, "linux-kernel" <linux-kernel@vger.kernel.org>, "RinHizakura"
> <s921975628@gmail.com>
> Gesendet: Samstag, 25. Dezember 2021 11:06:07
> Betreff: [PATCH 1/3] mtd: rawnand: nandsim: Replace overflow check with kzalloc to single kcalloc

> From: RinHizakura <s921975628@gmail.com>
> 
> Instead of self-checking overflow and allocating an array of specific size
> by counting the total required space handy, we already have existed kernel
> API which responses for all these works.
> 
> Signed-off-by: RinHizakura <s921975628@gmail.com>

Reviewed-by: Richard Weinberger <richard@nod.at>

Thanks,
//richard

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

* Re: [PATCH 1/3] mtd: rawnand: nandsim: Replace overflow check with kzalloc to single kcalloc
  2021-12-25 10:06 [PATCH 1/3] mtd: rawnand: nandsim: Replace overflow check with kzalloc to single kcalloc s921975628
  2021-12-25 21:09 ` Richard Weinberger
@ 2022-01-23 15:43 ` Miquel Raynal
  1 sibling, 0 replies; 3+ messages in thread
From: Miquel Raynal @ 2022-01-23 15:43 UTC (permalink / raw)
  To: s921975628; +Cc: richard, vigneshr, linux-mtd, linux-kernel

Hello,

s921975628@gmail.com wrote on Sat, 25 Dec 2021 18:06:07 +0800:

> From: RinHizakura <s921975628@gmail.com>
> 
> Instead of self-checking overflow and allocating an array of specific size
> by counting the total required space handy, we already have existed kernel
> API which responses for all these works.
> 
> Signed-off-by: RinHizakura <s921975628@gmail.com>

Series applied to nand/next.

Thanks,
Miquèl

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

end of thread, other threads:[~2022-01-23 15:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-25 10:06 [PATCH 1/3] mtd: rawnand: nandsim: Replace overflow check with kzalloc to single kcalloc s921975628
2021-12-25 21:09 ` Richard Weinberger
2022-01-23 15:43 ` 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).