mtd: Add check for devm_kcalloc()
commit 2aee30bb10d7bad0a60255059c9ce1b84cf0130e upstream.
Add a check for devm_kcalloc() to ensure successful allocation.
Fixes: 78c08247b9 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
91e1405088
commit
39fc127422
@@ -423,6 +423,9 @@ static void mtdpstore_notify_add(struct mtd_info *mtd)
|
||||
longcnt = BITS_TO_LONGS(div_u64(mtd->size, mtd->erasesize));
|
||||
cxt->badmap = kcalloc(longcnt, sizeof(long), GFP_KERNEL);
|
||||
|
||||
if (!cxt->rmmap || !cxt->usedmap || !cxt->badmap)
|
||||
return;
|
||||
|
||||
/* just support dmesg right now */
|
||||
cxt->dev.flags = PSTORE_FLAGS_DMESG;
|
||||
cxt->dev.zone.read = mtdpstore_read;
|
||||
|
||||
Reference in New Issue
Block a user