From 0be52de91c5e275dff61f0ed2314d84c9d68b385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Mon, 18 May 2015 14:37:27 +0200 Subject: [PATCH] drm/amdgpu: validate amdgpu_vm_bo_map parameters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König Reviewed-by: Jammy Zhou Reviewed-by: Alex Deucher --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 1cc01fb409dc..b25e533fd6e8 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -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))) { -- GitLab