summaryrefslogtreecommitdiff
path: root/drivers/regulator
diff options
context:
space:
mode:
authorJon Hunter <jonathanh@nvidia.com>2016-03-30 17:09:13 +0100
committerMark Brown <broonie@kernel.org>2016-03-30 11:03:54 -0700
commita2151374230820a3a6e654f2998b2a44dbfae4e1 (patch)
tree666f47abfa742a71fde56c3b5267db66410c896e /drivers/regulator
parent5e3ca2b349b1e2c80b060b51bbf2af37448fad85 (diff)
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 <jonathanh@nvidia.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/core.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index ab1838138877..fd0e4e37f4e1 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -3991,12 +3991,11 @@ regulator_register(const struct regulator_desc *regulator_desc,
}
rdev_init_debugfs(rdev);
+ mutex_unlock(&regulator_list_mutex);
/* try to resolve regulators supply since a new one was registered */
class_for_each_device(&regulator_class, NULL, NULL,
regulator_register_resolve_supply);
-out:
- mutex_unlock(&regulator_list_mutex);
kfree(config);
return rdev;
@@ -4007,15 +4006,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(&regulator_list_mutex);
+ kfree(config);
+ return ERR_PTR(ret);
}
EXPORT_SYMBOL_GPL(regulator_register);