Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: nand: Fix memory allocation in nanddev_bbt_init()

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: <stable@vger.kernel.org>
Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>

authored by

Frieder Schrempf and committed by
Boris Brezillon
40b41289 dc928431

+2 -1
+2 -1
drivers/mtd/nand/bbt.c
··· 27 27 unsigned int nwords = DIV_ROUND_UP(nblocks * bits_per_block, 28 28 BITS_PER_LONG); 29 29 30 - nand->bbt.cache = kzalloc(nwords, GFP_KERNEL); 30 + nand->bbt.cache = kcalloc(nwords, sizeof(*nand->bbt.cache), 31 + GFP_KERNEL); 31 32 if (!nand->bbt.cache) 32 33 return -ENOMEM; 33 34