drm/amdgpu: Free user pages if kvmalloc_array fails
authorPhilip Yang <Philip.Yang@amd.com>
Fri, 29 Apr 2022 00:17:38 +0000 (20:17 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 4 May 2022 13:53:40 +0000 (09:53 -0400)
To cleanup the BOs of bo_list which have got user pages.

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

index 67bd506..e05ace2 100644 (file)
@@ -543,7 +543,8 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
                                        GFP_KERNEL | __GFP_ZERO);
                if (!e->user_pages) {
                        DRM_ERROR("kvmalloc_array failure\n");
-                       return -ENOMEM;
+                       r = -ENOMEM;
+                       goto out_free_user_pages;
                }
 
                r = amdgpu_ttm_tt_get_user_pages(bo, e->user_pages);