diff options
author | Maxim Levitsky <maximlevitsky@gmail.com> | 2010-02-22 13:39:31 -0500 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2010-02-26 12:05:46 -0500 |
commit | 298304f1a554d44cf13391e531ced3cde69a8ce4 (patch) | |
tree | 586c6f1d99aa03856f057280ca6647089dfa8618 /drivers/mtd | |
parent | 048d87199566663e4edc4880df3703c04bcf41d9 (diff) |
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')
-rw-r--r-- | drivers/mtd/mtdblock.c | 3 | ||||
-rw-r--r-- | drivers/mtd/mtdblock_ro.c | 3 |
2 files changed, 4 insertions, 2 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) | |||
348 | if (!(mtd->flags & MTD_WRITEABLE)) | 348 | if (!(mtd->flags & MTD_WRITEABLE)) |
349 | dev->mbd.readonly = 1; | 349 | dev->mbd.readonly = 1; |
350 | 350 | ||
351 | add_mtd_blktrans_dev(&dev->mbd); | 351 | if (add_mtd_blktrans_dev(&dev->mbd)) |
352 | kfree(dev); | ||
352 | } | 353 | } |
353 | 354 | ||
354 | static void mtdblock_remove_dev(struct mtd_blktrans_dev *dev) | 355 | static void mtdblock_remove_dev(struct mtd_blktrans_dev *dev) |
diff --git a/drivers/mtd/mtdblock_ro.c b/drivers/mtd/mtdblock_ro.c index 54ff2880cf65..d0d3f79f9d03 100644 --- a/drivers/mtd/mtdblock_ro.c +++ b/drivers/mtd/mtdblock_ro.c | |||
@@ -43,7 +43,8 @@ static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
43 | dev->tr = tr; | 43 | dev->tr = tr; |
44 | dev->readonly = 1; | 44 | dev->readonly = 1; |
45 | 45 | ||
46 | add_mtd_blktrans_dev(dev); | 46 | if (add_mtd_blktrans_dev(dev)) |
47 | kfree(dev); | ||
47 | } | 48 | } |
48 | 49 | ||
49 | static void mtdblock_remove_dev(struct mtd_blktrans_dev *dev) | 50 | static void mtdblock_remove_dev(struct mtd_blktrans_dev *dev) |