From: Jon Hunter Date: Wed, 30 Mar 2016 16:09:13 +0000 (+0100) Subject: UPSTREAM: regulator: Fix deadlock during regulator registration X-Git-Tag: firefly_0821_release~469 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5dc7257e197d8d7c6e0289231f630a45ffc6fde2;p=firefly-linux-kernel-4.4.55.git UPSTREAM: regulator: Fix deadlock during regulator registration Commit 5e3ca2b349b1 ("regulator: Try to resolve regulators supplies on registration") added a call to regulator_resolve_supply() within regulator_register() where the regulator_list_mutex is held. This causes a deadlock to occur on the Tegra114 Dalmore board when the palmas PMIC is registered because regulator_register_resolve_supply() calls regulator_dev_lookup() which may try to acquire the regulator_list_mutex again. Fix this by releasing the mutex before calling regulator_register_resolve_supply() and update the error exit path to ensure the mutex is released on an error. [Made commit message more legible -- broonie] Signed-off-by: Jon Hunter Signed-off-by: Mark Brown (cherry picked from commit a2151374230820a3a6e654f2998b2a44dbfae4e1) Change-Id: I65ac4aeac254d2ef3f161c422b92defd5badbbc4 Signed-off-by: David Wu --- diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 0d57cd6c3f24..34ae2745d3f3 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -3998,12 +3998,11 @@ regulator_register(const struct regulator_desc *regulator_desc, } rdev_init_debugfs(rdev); + mutex_unlock(®ulator_list_mutex); /* try to resolve regulators supply since a new one was registered */ class_for_each_device(®ulator_class, NULL, NULL, regulator_register_resolve_supply); -out: - mutex_unlock(®ulator_list_mutex); kfree(config); return rdev; @@ -4014,15 +4013,16 @@ scrub: regulator_ena_gpio_free(rdev); device_unregister(&rdev->dev); /* device core frees rdev */ - rdev = ERR_PTR(ret); goto out; wash: regulator_ena_gpio_free(rdev); clean: kfree(rdev); - rdev = ERR_PTR(ret); - goto out; +out: + mutex_unlock(®ulator_list_mutex); + kfree(config); + return ERR_PTR(ret); } EXPORT_SYMBOL_GPL(regulator_register);