diff options
author | Niklas Cassel <nks@flawful.org> | 2015-01-31 20:08:50 -0500 |
---|---|---|
committer | Brian Norris <computersforpeace@gmail.com> | 2015-02-08 01:55:47 -0500 |
commit | e1dd8641c8c36ff4aacf24c7e2575770e30afbe5 (patch) | |
tree | f18a2defea3e8e741b572fe754a22124ea8323f7 | |
parent | d164ea32674ec82e80f480769ffcd2144f901380 (diff) |
mtd: avoid registering reboot notifier twice
Calling mtd_device_parse_register with the same mtd_info
(e.g. registering several partitions on a single device)
would add the same reboot notifier twice, causing an
infinte loop in notifier_chain_register during boot up.
Signed-off-by: Niklas Cassel <nks@flawful.org>
[Brian: add FIXME comments]
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
-rw-r--r-- | drivers/mtd/mtdcore.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index cbc0fc46d2d6..52eea932c312 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c | |||
@@ -577,7 +577,15 @@ int mtd_device_parse_register(struct mtd_info *mtd, const char * const *types, | |||
577 | err = -ENODEV; | 577 | err = -ENODEV; |
578 | } | 578 | } |
579 | 579 | ||
580 | if (mtd->_reboot) { | 580 | /* |
581 | * FIXME: some drivers unfortunately call this function more than once. | ||
582 | * So we have to check if we've already assigned the reboot notifier. | ||
583 | * | ||
584 | * Generally, we can make multiple calls work for most cases, but it | ||
585 | * does cause problems with parse_mtd_partitions() above (e.g., | ||
586 | * cmdlineparts will register partitions more than once). | ||
587 | */ | ||
588 | if (mtd->_reboot && !mtd->reboot_notifier.notifier_call) { | ||
581 | mtd->reboot_notifier.notifier_call = mtd_reboot_notifier; | 589 | mtd->reboot_notifier.notifier_call = mtd_reboot_notifier; |
582 | register_reboot_notifier(&mtd->reboot_notifier); | 590 | register_reboot_notifier(&mtd->reboot_notifier); |
583 | } | 591 | } |