summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/mtdblock.c
diff options
context:
space:
mode:
authorMaxim Levitsky <maximlevitsky@gmail.com>2010-02-22 19:39:31 +0100
committerDavid Woodhouse <David.Woodhouse@intel.com>2010-02-26 18:05:46 +0100
commit298304f1a554d44cf13391e531ced3cde69a8ce4 (patch)
tree586c6f1d99aa03856f057280ca6647089dfa8618 /drivers/mtd/mtdblock.c
parentmtd: blktrans: Hotplug fixes (diff)
downloadlinux-298304f1a554d44cf13391e531ced3cde69a8ce4.tar.xz
linux-298304f1a554d44cf13391e531ced3cde69a8ce4.zip
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>
Diffstat (limited to 'drivers/mtd/mtdblock.c')
-rw-r--r--drivers/mtd/mtdblock.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c
index 8e5da1e46076..7ce30a239ada 100644
--- a/drivers/mtd/mtdblock.c
+++ b/drivers/mtd/mtdblock.c
@@ -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)