UPSTREAM: regulator: Fix deadlock during regulator registration
authorJon Hunter <jonathanh@nvidia.com>
Wed, 30 Mar 2016 16:09:13 +0000 (17:09 +0100)
committerHuang, Tao <huangtao@rock-chips.com>
Mon, 6 Mar 2017 10:28:40 +0000 (18:28 +0800)
commit5dc7257e197d8d7c6e0289231f630a45ffc6fde2
tree4c753aa28c1a77208bec4c5b78567ab970e36f80
parentb63a6e6e3ff851090c3bdf666d480239e019fa7e
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 <jonathanh@nvidia.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
(cherry picked from commit a2151374230820a3a6e654f2998b2a44dbfae4e1)

Change-Id: I65ac4aeac254d2ef3f161c422b92defd5badbbc4
Signed-off-by: David Wu <david.wu@rock-chips.com>
drivers/regulator/core.c