aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Norris <computersforpeace@gmail.com>2015-06-01 19:17:19 -0400
committerBrian Norris <computersforpeace@gmail.com>2015-10-26 17:32:33 -0400
commit3e00ed0e984bbec47f5e531bad3cf36885aa5d83 (patch)
treef31e2ddcc7b34b98860ff7426458a52dd8b37537
parentaf30c0a00aa0d086a820c2ec75544c07611834d7 (diff)
mtd: fixup corner case error handling in mtd_device_parse_register()
Since commit 3efe41be224c ("mtd: implement common reboot notifier boilerplate"), we might try to register a reboot notifier for an MTD that failed to register. Let's avoid this by making the error path clearer. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Reviewed-by: Richard Weinberger <richard@nod.at>
-rw-r--r--drivers/mtd/mtdcore.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index bbcba0dbd5c3..a2e76ac9f1dc 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -588,9 +588,15 @@ int mtd_device_parse_register(struct mtd_info *mtd, const char * const *types,
588 else 588 else
589 ret = nr_parts; 589 ret = nr_parts;
590 } 590 }
591 /* Didn't come up with either parsed OR fallback partitions */
592 if (ret < 0) {
593 pr_info("mtd: failed to find partitions\n");
594 goto out;
595 }
591 596
592 if (ret >= 0) 597 ret = mtd_add_device_partitions(mtd, real_parts, ret);
593 ret = mtd_add_device_partitions(mtd, real_parts, ret); 598 if (ret)
599 goto out;
594 600
595 /* 601 /*
596 * FIXME: some drivers unfortunately call this function more than once. 602 * FIXME: some drivers unfortunately call this function more than once.
@@ -605,6 +611,7 @@ int mtd_device_parse_register(struct mtd_info *mtd, const char * const *types,
605 register_reboot_notifier(&mtd->reboot_notifier); 611 register_reboot_notifier(&mtd->reboot_notifier);
606 } 612 }
607 613
614out:
608 kfree(real_parts); 615 kfree(real_parts);
609 return ret; 616 return ret;
610} 617}