drm/i915: Grab dev->struct_mutex in i915_gem_pageflip_info
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 17 Jun 2014 20:34:37 +0000 (22:34 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 17 Jun 2014 22:48:36 +0000 (00:48 +0200)
We could walk of a bad list otherwise when someone concurrently
unbinds stuff for fun.

I've suspected this as the root-cause behind seemingly inconsistent
state, but alas it's not.

Acked-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_debugfs.c

index 8057fd4fc86c7d8545a447ad6d704f2324024816..76c2572872f65cff0047b0e06319db8cc59a1505 100644 (file)
@@ -513,6 +513,11 @@ static int i915_gem_pageflip_info(struct seq_file *m, void *data)
        struct drm_device *dev = node->minor->dev;
        unsigned long flags;
        struct intel_crtc *crtc;
+       int ret;
+
+       ret = mutex_lock_interruptible(&dev->struct_mutex);
+       if (ret)
+               return ret;
 
        for_each_intel_crtc(dev, crtc) {
                const char pipe = pipe_name(crtc->pipe);
@@ -554,6 +559,8 @@ static int i915_gem_pageflip_info(struct seq_file *m, void *data)
                spin_unlock_irqrestore(&dev->event_lock, flags);
        }
 
+       mutex_unlock(&dev->struct_mutex);
+
        return 0;
 }