drm/ttm: Fix an oops and sync object leak.
authorThomas Hellstrom <thellstrom@vmware.com>
Tue, 21 Jul 2009 15:45:13 +0000 (17:45 +0200)
committerDave Airlie <airlied@redhat.com>
Wed, 29 Jul 2009 05:56:04 +0000 (15:56 +1000)
The code was potentially dereferencig a NULL sync object pointer.
At the same time a sync object reference was potentially leaked.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/ttm/ttm_bo_util.c

index bdec583..3e5d0c4 100644 (file)
@@ -509,8 +509,8 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
        if (evict) {
                ret = ttm_bo_wait(bo, false, false, false);
                spin_unlock(&bo->lock);
-               driver->sync_obj_unref(&bo->sync_obj);
-
+               if (tmp_obj)
+                       driver->sync_obj_unref(&tmp_obj);
                if (ret)
                        return ret;
 
@@ -532,6 +532,8 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
 
                set_bit(TTM_BO_PRIV_FLAG_MOVING, &bo->priv_flags);
                spin_unlock(&bo->lock);
+               if (tmp_obj)
+                       driver->sync_obj_unref(&tmp_obj);
 
                ret = ttm_buffer_object_transfer(bo, &ghost_obj);
                if (ret)