summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrieder Schrempf <frieder.schrempf@kontron.de>2018-11-27 10:44:52 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-12-08 14:59:06 +0300
commit86e42924160397148957ac80a588fe45fafcac6a (patch)
tree0ee1ca410dcecd2ec38419f0c885b8e981b471e5
parentac8edc62e8134aac60a0370ca1442f6e29a1feb9 (diff)
downloadlinux-86e42924160397148957ac80a588fe45fafcac6a.tar.xz
mtd: nand: Fix memory allocation in nanddev_bbt_init()
commit 40b412897ccb4b98b2cfb2a0aaabed58dd9e2086 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/mtd/nand/bbt.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/mtd/nand/bbt.c b/drivers/mtd/nand/bbt.c
index 56cde38b92c0..044adf913854 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;