mtd: rawnand: nandsim: Replace overflow check with kzalloc to single kcalloc
Subsystems (2)
PATCH 1/3 mtd: rawnand: nandsim: Replace overflow check with kzalloc to single kcalloc
From: RinHizakura <[email protected]>
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.
--- drivers/mtd/nand/raw/nandsim.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/mtd/nand/raw/nandsim.c +1 -8
@@ -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 ;
Signature · 1 line
2.25.1
----- Ursprüngliche Mail -----
Quoted 7 lines
Von: [email protected]
An: "richard" <[email protected]>, "Vignesh Raghavendra" <[email protected]>, "Miquel Raynal" <[email protected]>
CC: "linux-mtd" <[email protected]>, "linux-kernel" <[email protected]>, "RinHizakura" <[email protected]>
Gesendet: Samstag, 25. Dezember 2021 11:06:07
Betreff: [PATCH 1/3] mtd: rawnand: nandsim: Replace overflow check with kzalloc to single kcalloc
Quoted 7 lines
From: RinHizakura <[email protected]>
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 <[email protected]>
Thanks,
//richard
Miquel Raynal
maintainerHello,
[email protected] wrote on Sat, 25 Dec 2021 18:06:07 +0800:
Quoted 7 lines
From: RinHizakura <[email protected]>
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 <[email protected]>
Series applied to nand/next.
Thanks,
Miquèl