projects/linux·commit 40b41289

mtd: nand: Fix memory allocation in nanddev_bbt_init()

40b41289 · Frieder Schrempf <[email protected]> · 2018-11-27 07:44:52 +00:00

Fix the size of the buffer allocated to store the in-memory BBT.
This bug was previously hidden by a different bug, that was fixed in
commit d098093ba06e ("mtd: nand: Fix nanddev_neraseblocks()").

Fixes: 9c3736a3de21 ("mtd: nand: Add core infrastructure to deal with NAND devices")
Cc: <[email protected]>
Signed-off-by: Frieder Schrempf <[email protected]>
Acked-by: Miquel Raynal <[email protected]>
Signed-off-by: Boris Brezillon <[email protected]>
Commit
40b412897ccb4b98b2cfb2a0aaabed58dd9e2086
Parents
dc928431

Changes

1 files changed · +2 −1

FileStatusAddDelContent
drivers/mtd/nand/bbt.cmodified+2−1View file

drivers/mtd/nand/bbt.c

View file
diff --git a/drivers/mtd/nand/bbt.c b/drivers/mtd/nand/bbt.c
index 56cde38..044adf9 100644
--- a/drivers/mtd/nand/bbt.c
+++ b/drivers/mtd/nand/bbt.c
@@ -27,7 +27,8 @@ int nanddev_bbt_init(struct nand_device *nand)
unsigned int nwords = DIV_ROUND_UP(nblocks * bits_per_block,
BITS_PER_LONG);
- nand->bbt.cache = kzalloc(nwords, GFP_KERNEL);
+ nand->bbt.cache = kcalloc(nwords, sizeof(*nand->bbt.cache),
+ GFP_KERNEL);
if (!nand->bbt.cache)
return -ENOMEM;