diff options
author | Charles Keepax <ckeepax@opensource.cirrus.com> | 2019-04-04 16:32:18 +0100 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2019-04-05 09:35:36 +0700 |
commit | 063773011d33bb36588a90385aa9eb75d13c6d80 (patch) | |
tree | 9dff117a42633721819f01b01744ccaf1a65d504 /drivers/spi/spi-dw.c | |
parent | 0b5e200cc7ee339694693a6d89816b66ccbd663a (diff) | |
download | linux-063773011d33bb36588a90385aa9eb75d13c6d80.tar.bz2 |
regulator: core: Avoid potential deadlock on regulator_unregister
Lockdep reports the following issue on my setup:
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock((work_completion)(&(&rdev->disable_work)->work));
lock(regulator_list_mutex);
lock((work_completion)(&(&rdev->disable_work)->work));
lock(regulator_list_mutex);
The problem is that regulator_unregister takes the
regulator_list_mutex and then calls flush_work on disable_work. But
regulator_disable_work calls regulator_lock_dependent which will
also take the regulator_list_mutex. Resulting in a deadlock if the
flush_work call actually needs to flush the work.
Fix this issue by moving the flush_work outside of the
regulator_list_mutex. The list mutex is not used to guard the point at
which the delayed work is queued, so its use adds no additional safety.
Fixes: f8702f9e4aa7 ("regulator: core: Use ww_mutex for regulators locking")
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi-dw.c')
0 files changed, 0 insertions, 0 deletions