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

mtd: Add check for devm_kcalloc()

Add a check for devm_kcalloc() to ensure successful allocation.

Fixes: 78c08247b9d3 ("mtd: Support kmsg dumper based on pstore/blk")
Cc: stable@vger.kernel.org # v5.10+
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

authored by

Jiasheng Jiang and committed by
Miquel Raynal
2aee30bb 1b61a598

+3
+3
drivers/mtd/mtdpstore.c
··· 423 423 longcnt = BITS_TO_LONGS(div_u64(mtd->size, mtd->erasesize)); 424 424 cxt->badmap = devm_kcalloc(&mtd->dev, longcnt, sizeof(long), GFP_KERNEL); 425 425 426 + if (!cxt->rmmap || !cxt->usedmap || !cxt->badmap) 427 + return; 428 + 426 429 /* just support dmesg right now */ 427 430 cxt->dev.flags = PSTORE_FLAGS_DMESG; 428 431 cxt->dev.zone.read = mtdpstore_read;