From: Flora Cui Date: Thu, 18 Aug 2016 04:55:13 +0000 (+0800) Subject: drm/amdgpu: check domain sanity in amdgpu_bo_pin_restricted() X-Git-Tag: v4.9-rc1~41^2~35^2~34 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=408778e8e9656105aa4df2fe7dce54244ccdd3d7;p=karo-tx-linux.git drm/amdgpu: check domain sanity in amdgpu_bo_pin_restricted() abort if the bo is pined to other domain already Signed-off-by: Flora Cui Reviewed-by: Michel Dänzer Reviewed-by: Christian König Signed-off-by: Alex Deucher --- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 4d084eeb4e09..0a0f3cb89f92 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -520,6 +520,11 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain, return -EINVAL; if (bo->pin_count) { + uint32_t mem_type = bo->tbo.mem.mem_type; + + if (domain != amdgpu_mem_type_to_domain(mem_type)) + return -EINVAL; + bo->pin_count++; if (gpu_addr) *gpu_addr = amdgpu_bo_gpu_offset(bo);