Thread (24 messages) 24 messages, 3 authors, 2021-08-19
STALE1797d

[PATCH v3 2/9] drm: hold master_lookup_lock when releasing a drm_file's master

From: Desmond Cheong Zhi Xi <hidden>
Date: 2021-08-18 07:40:31
Also in: dri-devel, intel-gfx, linux-media, lkml
Subsystem: drm drivers, drm drivers and misc gpu patches, the rest · Maintainers: David Airlie, Simona Vetter, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Linus Torvalds

When drm_file.master changes value, the corresponding
drm_device.master_lookup_lock should be held.

In drm_master_release, a call to drm_master_put sets the
file_priv->master to NULL, so we protect this section with
drm_device.master_lookup_lock.

Signed-off-by: Desmond Cheong Zhi Xi <redacted>
---
 drivers/gpu/drm/drm_auth.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c
index 8efb58aa7d95..8c0e0dba1611 100644
--- a/drivers/gpu/drm/drm_auth.c
+++ b/drivers/gpu/drm/drm_auth.c
@@ -373,8 +373,11 @@ void drm_master_release(struct drm_file *file_priv)
 	}
 
 	/* drop the master reference held by the file priv */
-	if (file_priv->master)
+	if (file_priv->master) {
+		spin_lock(&dev->master_lookup_lock);
 		drm_master_put(&file_priv->master);
+		spin_unlock(&dev->master_lookup_lock);
+	}
 	mutex_unlock(&dev->master_mutex);
 }
 
-- 
2.25.1

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help