mtd: mtdblock: test return value of add_mtd_blktrans_dev, because if can fail
This prevents a memory leak Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
This commit is contained in:
parent
048d871995
commit
298304f1a5
|
@ -348,7 +348,8 @@ static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
|
|||
if (!(mtd->flags & MTD_WRITEABLE))
|
||||
dev->mbd.readonly = 1;
|
||||
|
||||
add_mtd_blktrans_dev(&dev->mbd);
|
||||
if (add_mtd_blktrans_dev(&dev->mbd))
|
||||
kfree(dev);
|
||||
}
|
||||
|
||||
static void mtdblock_remove_dev(struct mtd_blktrans_dev *dev)
|
||||
|
|
|
@ -43,7 +43,8 @@ static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
|
|||
dev->tr = tr;
|
||||
dev->readonly = 1;
|
||||
|
||||
add_mtd_blktrans_dev(dev);
|
||||
if (add_mtd_blktrans_dev(dev))
|
||||
kfree(dev);
|
||||
}
|
||||
|
||||
static void mtdblock_remove_dev(struct mtd_blktrans_dev *dev)
|
||||
|
|
Loading…
Reference in a new issue