diff options
author | RinHizakura <s921975628@gmail.com> | 2021-12-25 11:06:07 +0100 |
---|---|---|
committer | Miquel Raynal <miquel.raynal@bootlin.com> | 2022-01-23 16:37:04 +0100 |
commit | e0a9ddd5d9e1c66caefda825b3cea8ea9bd21bf0 (patch) | |
tree | 095342bc10427c6fc0fba60f302c64bad6c990d2 /drivers/mtd | |
parent | Linux 5.17-rc1 (diff) | |
download | linux-e0a9ddd5d9e1c66caefda825b3cea8ea9bd21bf0.tar.xz linux-e0a9ddd5d9e1c66caefda825b3cea8ea9bd21bf0.zip |
mtd: rawnand: nandsim: Replace overflow check with kzalloc to single kcalloc
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>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20211225100607.118932-1-s921975628@gmail.com
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/nand/raw/nandsim.c | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/drivers/mtd/nand/raw/nandsim.c b/drivers/mtd/nand/raw/nandsim.c index 0750121ac371..3698fb430f81 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; |