[PATCH] mtd: fix error path in physmap.c
H Hartley Sweeten
hartleys at visionengravers.com
Tue Oct 20 21:09:22 EDT 2009
During the physmap probe, add_mtd_partitions() and add_mtd_device()
can both return an error. Add an error path to handle this.
Signed-off-by: H Hartley Sweeten <hsweeten at visionengravers.com>
Cc: David Woodhouse <dwmw2 at infradead.org>
---
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index 3f13a96..966b25d 100644
--- a/drivers/mtd/maps/physmap.c
+++ b/drivers/mtd/maps/physmap.c
@@ -169,24 +169,28 @@ static int physmap_flash_probe(struct platform_device *dev)
goto err_out;
#ifdef CONFIG_MTD_PARTITIONS
- err = parse_mtd_partitions(info->cmtd, part_probe_types,
- &info->parts, 0);
- if (err > 0) {
- add_mtd_partitions(info->cmtd, info->parts, err);
- info->nr_parts = err;
- return 0;
+ info->nr_parts = parse_mtd_partitions(info->cmtd, part_probe_types,
+ &info->parts, 0);
+ if (info->nr_parts > 0) {
+ err = add_mtd_partitions(info->cmtd, info->parts,
+ info->nr_parts);
+ goto out;
}
if (physmap_data->nr_parts) {
printk(KERN_NOTICE "Using physmap partition information\n");
- add_mtd_partitions(info->cmtd, physmap_data->parts,
- physmap_data->nr_parts);
- return 0;
+ err = add_mtd_partitions(info->cmtd, physmap_data->parts,
+ physmap_data->nr_parts);
+ goto out;
}
#endif
- add_mtd_device(info->cmtd);
- return 0;
+ if (add_mtd_device(info->cmtd) == 1)
+ err = -ENODEV;
+
+out:
+ if (!err)
+ return 0;
err_out:
physmap_flash_remove(dev);
More information about the linux-mtd
mailing list