Subject: Re: [PATCH net,v2] team: Fix ABBA deadlock caused by race in team_del_slave

From: Stephen Hemminger <[email-masked]>
Date: Sat, 6 Jul 2024 08:01:02 -0700

On Sat,  6 Jul 2024 13:13:29 +0900
Jeongjun Park <[email-masked]> wrote:

>        CPU0                    CPU1
>        ----                    ----
>   lock(&rdev->wiphy.mtx);
>                                lock(team->team_lock_key#4);
>                                lock(&rdev->wiphy.mtx);
>   lock(team->team_lock_key#4);
> 
> Deadlock occurs due to the above scenario. Therefore, you can prevent
> deadlock by briefly releasing the lock before calling dev_open() in
> team_port_add() and locking it again after it returns.
> 
> Reported-and-tested-by: [email-masked]
> Fixes: 3d249d4ca7d0 ("net: introduce ethernet teaming device")
> Signed-off-by: Jeongjun Park <[email-masked]>
> ---

But if you drop the lock the actual data structures might have changed.
Usually not a good idea,