Re: [RFC PATCH] regulator: core: Move device_link_remove out from regulator_list_mutex
From: Mark Brown
Date: Thu Jul 18 2019 - 07:45:24 EST
On Thu, Jul 18, 2019 at 02:42:26PM +0800, Yong Wu wrote:
> The MediaTek SMI adding device_link patch looks reveal a deadlock
> issue reported in [1], This patch is to fix this deadlock issue.
Can you please describe in words what this issue is and how the patch
addresses it?
> This is the detailed log:
>
> [ 4.664194] ======================================================
> [ 4.670368] WARNING: possible circular locking dependency detected
> [ 4.676545] 5.2.0-rc2-next-20190528-44527-g6c94b6475c04 #20 Tainted: G S
> [ 4.684539] ------------------------------------------------------
Please think hard before including complete backtraces in upstream
reports, they are very large and contain almost no useful information
relative to their size so often obscure the relevant content in your
message. If part of the backtrace is usefully illustrative then it's
usually better to pull out the relevant sections.
> index 955a0a1..3db9350 100644
> --- a/drivers/regulator/core.c
> +++ b/drivers/regulator/core.c
> @@ -2048,7 +2048,9 @@ static void _regulator_put(struct regulator *regulator)
> debugfs_remove_recursive(regulator->debugfs);
>
> if (regulator->dev) {
> + mutex_unlock(®ulator_list_mutex);
> device_link_remove(regulator->dev, &rdev->dev);
> + mutex_lock(®ulator_list_mutex);
>
> /* remove any sysfs entries */
> sysfs_remove_link(&rdev->dev.kobj, regulator->supply_name);
> --
> 1.9.1
>
Just randomly dropping and reacquiring the lock in the middle of a
series of operations sounds potentially racy... What happens if the
list gets changed while the lock is dropped?
Attachment:
signature.asc
Description: PGP signature