Commit 3e00ed0e authored by Brian Norris's avatar Brian Norris

mtd: fixup corner case error handling in mtd_device_parse_register()

Since commit 3efe41be ("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: default avatarBrian Norris <computersforpeace@gmail.com>
Reviewed-by: default avatarRichard Weinberger <richard@nod.at>
parent af30c0a0
...@@ -588,9 +588,15 @@ int mtd_device_parse_register(struct mtd_info *mtd, const char * const *types, ...@@ -588,9 +588,15 @@ int mtd_device_parse_register(struct mtd_info *mtd, const char * const *types,
else else
ret = nr_parts; ret = nr_parts;
} }
/* Didn't come up with either parsed OR fallback partitions */
if (ret < 0) {
pr_info("mtd: failed to find partitions\n");
goto out;
}
if (ret >= 0) ret = mtd_add_device_partitions(mtd, real_parts, ret);
ret = mtd_add_device_partitions(mtd, real_parts, ret); if (ret)
goto out;
/* /*
* FIXME: some drivers unfortunately call this function more than once. * 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,6 +611,7 @@ int mtd_device_parse_register(struct mtd_info *mtd, const char * const *types,
register_reboot_notifier(&mtd->reboot_notifier); register_reboot_notifier(&mtd->reboot_notifier);
} }
out:
kfree(real_parts); kfree(real_parts);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment