diff mbox

drm_open doesnt lock before increasing dev->open_count

Message ID 849307$bfi2og@azsmga001.ch.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson Feb. 7, 2011, 11:18 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 2ec7d48..5b4ca5b 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -125,6 +125,13 @@  int drm_open(struct inode *inode, struct file *filp)
        struct drm_minor *minor;
        int retcode = 0;
 
+       /* Typically we are called (via the driver) from drm_stub_open()
+        * as their own fops->open and so already hold the global mutex.
+        * Enforce this.
+        */
+       if (WARN_ON(!mutex_is_locked(&drm_global_mutex)))
+               return -EINVAL;
+
        minor = idr_find(&drm_minors_idr, minor_id);
        if (!minor)
                return -ENODEV;