Skip to content

Commit 28be240

Browse files
desmondcheongzxdanvet
authored andcommitted
drm: use the lookup lock in drm_is_current_master
Inside drm_is_current_master, using the outer drm_device.master_mutex to protect reads of drm_file.master makes the function prone to creating lock hierarchy inversions. Instead, we can use the drm_file.master_lookup_lock that sits at the bottom of the lock hierarchy. Reported-by: Daniel Vetter <[email protected]> Signed-off-by: Desmond Cheong Zhi Xi <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent c29758c commit 28be240

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/gpu/drm/drm_auth.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@
6363

6464
static bool drm_is_current_master_locked(struct drm_file *fpriv)
6565
{
66-
lockdep_assert_held_once(&fpriv->minor->dev->master_mutex);
67-
66+
/* Either drm_device.master_mutex or drm_file.master_lookup_lock
67+
* should be held here.
68+
*/
6869
return fpriv->is_master && drm_lease_owner(fpriv->master) == fpriv->minor->dev->master;
6970
}
7071

@@ -82,9 +83,9 @@ bool drm_is_current_master(struct drm_file *fpriv)
8283
{
8384
bool ret;
8485

85-
mutex_lock(&fpriv->minor->dev->master_mutex);
86+
spin_lock(&fpriv->master_lookup_lock);
8687
ret = drm_is_current_master_locked(fpriv);
87-
mutex_unlock(&fpriv->minor->dev->master_mutex);
88+
spin_unlock(&fpriv->master_lookup_lock);
8889

8990
return ret;
9091
}

0 commit comments

Comments
 (0)