diff options
-rw-r--r-- | include/drm/drm_gem.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h index 1e6ae1458f7a..7a592d7e398b 100644 --- a/include/drm/drm_gem.h +++ b/include/drm/drm_gem.h | |||
@@ -149,14 +149,16 @@ drm_gem_object_unreference(struct drm_gem_object *obj) | |||
149 | static inline void | 149 | static inline void |
150 | drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) | 150 | drm_gem_object_unreference_unlocked(struct drm_gem_object *obj) |
151 | { | 151 | { |
152 | if (obj && !atomic_add_unless(&obj->refcount.refcount, -1, 1)) { | 152 | struct drm_device *dev; |
153 | struct drm_device *dev = obj->dev; | 153 | |
154 | if (!obj) | ||
155 | return; | ||
154 | 156 | ||
155 | mutex_lock(&dev->struct_mutex); | 157 | dev = obj->dev; |
156 | if (likely(atomic_dec_and_test(&obj->refcount.refcount))) | 158 | if (kref_put_mutex(&obj->refcount, drm_gem_object_free, &dev->struct_mutex)) |
157 | drm_gem_object_free(&obj->refcount); | ||
158 | mutex_unlock(&dev->struct_mutex); | 159 | mutex_unlock(&dev->struct_mutex); |
159 | } | 160 | else |
161 | might_lock(&dev->struct_mutex); | ||
160 | } | 162 | } |
161 | 163 | ||
162 | int drm_gem_handle_create(struct drm_file *file_priv, | 164 | int drm_gem_handle_create(struct drm_file *file_priv, |