drm/amdgpu: validate amdgpu_vm_bo_map parameters
authorChristian König <christian.koenig@amd.com>
Mon, 18 May 2015 12:37:27 +0000 (14:37 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 4 Jun 2015 01:03:43 +0000 (21:03 -0400)
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

index 1cc01fb409dc1c8c283a75810f45f7e874ddfb42..b25e533fd6e8f53050cd37721cfc449673d179f7 100644 (file)
@@ -936,6 +936,13 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev,
        uint64_t eaddr;
        int r;
 
+       /* validate the parameters */
+       if (saddr & AMDGPU_GPU_PAGE_MASK || offset & AMDGPU_GPU_PAGE_MASK ||
+           size == 0 || size & AMDGPU_GPU_PAGE_MASK) {
+               amdgpu_bo_unreserve(bo_va->bo);
+               return -EINVAL;
+       }
+
        /* make sure object fit at this offset */
        eaddr = saddr + size;
        if ((saddr >= eaddr) || (offset + size > amdgpu_bo_size(bo_va->bo))) {