Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e1dd8641 authored by Niklas Cassel's avatar Niklas Cassel Committed by Brian Norris
Browse files

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: default avatarNiklas Cassel <nks@flawful.org>
[Brian: add FIXME comments]
Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>

Signed-off-by: default avatarBrian Norris <computersforpeace@gmail.com>
parent d164ea32
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -577,7 +577,15 @@ int mtd_device_parse_register(struct mtd_info *mtd, const char * const *types,
			err = -ENODEV;
	}

	if (mtd->_reboot) {
	/*
	 * FIXME: some drivers unfortunately call this function more than once.
	 * So we have to check if we've already assigned the reboot notifier.
	 *
	 * Generally, we can make multiple calls work for most cases, but it
	 * does cause problems with parse_mtd_partitions() above (e.g.,
	 * cmdlineparts will register partitions more than once).
	 */
	if (mtd->_reboot && !mtd->reboot_notifier.notifier_call) {
		mtd->reboot_notifier.notifier_call = mtd_reboot_notifier;
		register_reboot_notifier(&mtd->reboot_notifier);
	}