drm/amdgpu: check domain sanity in amdgpu_bo_pin_restricted()
authorFlora Cui <Flora.Cui@amd.com>
Thu, 18 Aug 2016 04:55:13 +0000 (12:55 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 19 Aug 2016 16:31:19 +0000 (12:31 -0400)
abort if the bo is pined to other domain already

Signed-off-by: Flora Cui <Flora.Cui@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c

index 4d084eeb4e09fe2677cefa9c23c423b42a84d4b8..0a0f3cb89f92089ee02afa4e1ca8b0cc0e44231e 100644 (file)
@@ -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);