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:
Maxim Levitsky 2010-02-22 20:39:31 +02:00 коммит произвёл David Woodhouse
Родитель 048d871995
Коммит 298304f1a5
2 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -348,7 +348,8 @@ static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
if (!(mtd->flags & MTD_WRITEABLE)) if (!(mtd->flags & MTD_WRITEABLE))
dev->mbd.readonly = 1; 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) 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->tr = tr;
dev->readonly = 1; 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) static void mtdblock_remove_dev(struct mtd_blktrans_dev *dev)