drm/amdgpu: fix error handling in amdgpu_bo_list_set
authorChristian König <christian.koenig@amd.com>
Mon, 22 Feb 2016 14:11:56 +0000 (15:11 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 26 Feb 2016 06:50:18 +0000 (01:50 -0500)
Don't leak BOs in case of some error.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c

index 90d6fc1618aa33074fb99eb806e3a5b17307228f..4792f9d0b7d40ff33d616b3a8daeb027e5d4698e 100644 (file)
@@ -118,6 +118,7 @@ static int amdgpu_bo_list_set(struct amdgpu_device *adev,
                usermm = amdgpu_ttm_tt_get_usermm(entry->robj->tbo.ttm);
                if (usermm) {
                        if (usermm != current->mm) {
+                               amdgpu_bo_unref(&entry->robj);
                                r = -EPERM;
                                goto error_free;
                        }
@@ -151,6 +152,8 @@ static int amdgpu_bo_list_set(struct amdgpu_device *adev,
        return 0;
 
 error_free:
+       while (i--)
+               amdgpu_bo_unref(&array[i].robj);
        drm_free_large(array);
        return r;
 }