Skip to content

Commit 2aee30b

Browse files
Jiasheng Jiangmiquelraynal
authored andcommitted
mtd: Add check for devm_kcalloc()
Add a check for devm_kcalloc() to ensure successful allocation. Fixes: 78c0824 ("mtd: Support kmsg dumper based on pstore/blk") Cc: [email protected] # v5.10+ Signed-off-by: Jiasheng Jiang <[email protected]> Signed-off-by: Miquel Raynal <[email protected]>
1 parent 1b61a59 commit 2aee30b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/mtd/mtdpstore.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,9 @@ static void mtdpstore_notify_add(struct mtd_info *mtd)
423423
longcnt = BITS_TO_LONGS(div_u64(mtd->size, mtd->erasesize));
424424
cxt->badmap = devm_kcalloc(&mtd->dev, longcnt, sizeof(long), GFP_KERNEL);
425425

426+
if (!cxt->rmmap || !cxt->usedmap || !cxt->badmap)
427+
return;
428+
426429
/* just support dmesg right now */
427430
cxt->dev.flags = PSTORE_FLAGS_DMESG;
428431
cxt->dev.zone.read = mtdpstore_read;

0 commit comments

Comments
 (0)