mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-12-22 18:47:06 +01:00
mtd: Replace kcalloc() with devm_kcalloc()
commit1b61a59876upstream. Replace kcalloc() with devm_kcalloc() to prevent memory leaks in case of errors. 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:
parent
64baf64684
commit
ce6cabc080
|
|
@ -417,11 +417,11 @@ static void mtdpstore_notify_add(struct mtd_info *mtd)
|
|||
}
|
||||
|
||||
longcnt = BITS_TO_LONGS(div_u64(mtd->size, info->kmsg_size));
|
||||
cxt->rmmap = kcalloc(longcnt, sizeof(long), GFP_KERNEL);
|
||||
cxt->usedmap = kcalloc(longcnt, sizeof(long), GFP_KERNEL);
|
||||
cxt->rmmap = devm_kcalloc(&mtd->dev, longcnt, sizeof(long), GFP_KERNEL);
|
||||
cxt->usedmap = devm_kcalloc(&mtd->dev, longcnt, sizeof(long), GFP_KERNEL);
|
||||
|
||||
longcnt = BITS_TO_LONGS(div_u64(mtd->size, mtd->erasesize));
|
||||
cxt->badmap = kcalloc(longcnt, sizeof(long), GFP_KERNEL);
|
||||
cxt->badmap = devm_kcalloc(&mtd->dev, longcnt, sizeof(long), GFP_KERNEL);
|
||||
|
||||
if (!cxt->rmmap || !cxt->usedmap || !cxt->badmap)
|
||||
return;
|
||||
|
|
@ -530,9 +530,6 @@ static void mtdpstore_notify_remove(struct mtd_info *mtd)
|
|||
mtdpstore_flush_removed(cxt);
|
||||
|
||||
unregister_pstore_device(&cxt->dev);
|
||||
kfree(cxt->badmap);
|
||||
kfree(cxt->usedmap);
|
||||
kfree(cxt->rmmap);
|
||||
cxt->mtd = NULL;
|
||||
cxt->index = -1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user