linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: nand: Fix memory allocation in nanddev_bbt_init()
@ 2018-11-27  7:44 Schrempf Frieder
  2018-11-27  8:22 ` Boris Brezillon
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Schrempf Frieder @ 2018-11-27  7:44 UTC (permalink / raw)
  To: Boris Brezillon, Miquel Raynal, Richard Weinberger
  Cc: Schrempf Frieder, stable, David Woodhouse, Brian Norris,
	Marek Vasut, linux-mtd, linux-kernel

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
d098093ba06e.

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>
---
 drivers/mtd/nand/bbt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/bbt.c b/drivers/mtd/nand/bbt.c
index 56cde38..c12497f 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 = kzalloc(nwords * (BITS_PER_LONG / BITS_PER_BYTE),
+				  GFP_KERNEL);
 	if (!nand->bbt.cache)
 		return -ENOMEM;
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-11-30  9:37 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-27  7:44 [PATCH] mtd: nand: Fix memory allocation in nanddev_bbt_init() Schrempf Frieder
2018-11-27  8:22 ` Boris Brezillon
2018-11-27  8:30   ` Schrempf Frieder
2018-11-27  9:27     ` Miquel Raynal
2018-11-28 14:41 ` Boris Brezillon
2018-11-28 14:55   ` Schrempf Frieder
2018-11-28 15:02     ` Boris Brezillon
2018-11-28 15:19       ` Schrempf Frieder
2018-11-28 15:28         ` Boris Brezillon
2018-11-29 18:11           ` Schrempf Frieder
2018-11-30  9:37 ` Boris Brezillon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).