Skip to content

Commit

Permalink
drm/gem: Check locking in drm_gem_object_unreference
Browse files Browse the repository at this point in the history
Pretty soon only some drivers will need dev->struct_mutex in their
gem_free_object callbacks. Hence it's really important to make sure
everything still keeps getting this right.

v2: Don't check for locking before we check for non-NULL obj. Spotted
by Dan Carpenter.

Link: http://mid.gmane.org/1444894601-5200-10-git-send-email-daniel.vetter@ffwll.ch
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
  • Loading branch information
Daniel Vetter committed Oct 19, 2015
1 parent 4e270f0 commit ef4c627
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion include/drm/drm_gem.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,11 @@ drm_gem_object_reference(struct drm_gem_object *obj)
static inline void
drm_gem_object_unreference(struct drm_gem_object *obj)
{
if (obj != NULL)
if (obj != NULL) {
WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex));

kref_put(&obj->refcount, drm_gem_object_free);
}
}

static inline void
Expand Down

0 comments on commit ef4c627

Please sign in to comment.