Skip to content

Commit

Permalink
drm/cma-helper: Fix locking in drm_fb_cma_debugfs_show
Browse files Browse the repository at this point in the history
This function takes two locks, both of them the wrong ones. This
wasn't an oversight from my fb locking rework since both patches
landed in parallel. We really only need fb_lock when walking that
list, since everything we can reach from that is refcounted properly
already.

v2: Drop unused dev spotted by 0day.

Cc: Rob Clark <robdclark@gmail.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
  • Loading branch information
Daniel Vetter committed Jul 22, 2015
1 parent 9a9f5ce commit 9e75c0e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
16 changes: 2 additions & 14 deletions drivers/gpu/drm/drm_fb_cma_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,23 +209,11 @@ int drm_fb_cma_debugfs_show(struct seq_file *m, void *arg)
struct drm_info_node *node = (struct drm_info_node *) m->private;
struct drm_device *dev = node->minor->dev;
struct drm_framebuffer *fb;
int ret;

ret = mutex_lock_interruptible(&dev->mode_config.mutex);
if (ret)
return ret;

ret = mutex_lock_interruptible(&dev->struct_mutex);
if (ret) {
mutex_unlock(&dev->mode_config.mutex);
return ret;
}

mutex_lock(&dev->mode_config.fb_lock);
list_for_each_entry(fb, &dev->mode_config.fb_list, head)
drm_fb_cma_describe(fb, m);

mutex_unlock(&dev->struct_mutex);
mutex_unlock(&dev->mode_config.mutex);
mutex_unlock(&dev->mode_config.fb_lock);

return 0;
}
Expand Down
3 changes: 0 additions & 3 deletions drivers/gpu/drm/drm_gem_cma_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,8 @@ void drm_gem_cma_describe(struct drm_gem_cma_object *cma_obj,
struct seq_file *m)
{
struct drm_gem_object *obj = &cma_obj->base;
struct drm_device *dev = obj->dev;
uint64_t off;

WARN_ON(!mutex_is_locked(&dev->struct_mutex));

off = drm_vma_node_start(&obj->vma_node);

seq_printf(m, "%2d (%2d) %08llx %pad %p %zu",
Expand Down

0 comments on commit 9e75c0e

Please sign in to comment.