From: Christian König Date: Mon, 22 Feb 2016 14:11:56 +0000 (+0100) Subject: drm/amdgpu: fix error handling in amdgpu_bo_list_set X-Git-Tag: next-20160308~70^2^2~6 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=70eacc72dbbc229013fee54550c03179f9a513d8;p=karo-tx-linux.git drm/amdgpu: fix error handling in amdgpu_bo_list_set Don't leak BOs in case of some error. Signed-off-by: Christian König Reviewed-by: Alex Deucher --- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c index 90d6fc1618aa..4792f9d0b7d4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c @@ -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; }