Commit 7ecc245a authored by Christian König's avatar Christian König Committed by Alex Deucher

drm/amdgpu: consistent use u64_to_user_ptr

Instead of open coding the conversion from u64 to pointers.
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent f5e1c740
...@@ -270,7 +270,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data, ...@@ -270,7 +270,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,
struct amdgpu_fpriv *fpriv = filp->driver_priv; struct amdgpu_fpriv *fpriv = filp->driver_priv;
union drm_amdgpu_bo_list *args = data; union drm_amdgpu_bo_list *args = data;
uint32_t handle = args->in.list_handle; uint32_t handle = args->in.list_handle;
const void __user *uptr = (const void*)(uintptr_t)args->in.bo_info_ptr; const void __user *uptr = u64_to_user_ptr(args->in.bo_info_ptr);
struct drm_amdgpu_bo_list_entry *info; struct drm_amdgpu_bo_list_entry *info;
struct amdgpu_bo_list *list; struct amdgpu_bo_list *list;
......
...@@ -90,7 +90,7 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data) ...@@ -90,7 +90,7 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data)
} }
/* get chunks */ /* get chunks */
chunk_array_user = (uint64_t __user *)(uintptr_t)(cs->in.chunks); chunk_array_user = u64_to_user_ptr(cs->in.chunks);
if (copy_from_user(chunk_array, chunk_array_user, if (copy_from_user(chunk_array, chunk_array_user,
sizeof(uint64_t)*cs->in.num_chunks)) { sizeof(uint64_t)*cs->in.num_chunks)) {
ret = -EFAULT; ret = -EFAULT;
...@@ -110,7 +110,7 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data) ...@@ -110,7 +110,7 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data)
struct drm_amdgpu_cs_chunk user_chunk; struct drm_amdgpu_cs_chunk user_chunk;
uint32_t __user *cdata; uint32_t __user *cdata;
chunk_ptr = (void __user *)(uintptr_t)chunk_array[i]; chunk_ptr = u64_to_user_ptr(chunk_array[i]);
if (copy_from_user(&user_chunk, chunk_ptr, if (copy_from_user(&user_chunk, chunk_ptr,
sizeof(struct drm_amdgpu_cs_chunk))) { sizeof(struct drm_amdgpu_cs_chunk))) {
ret = -EFAULT; ret = -EFAULT;
...@@ -121,7 +121,7 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data) ...@@ -121,7 +121,7 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data)
p->chunks[i].length_dw = user_chunk.length_dw; p->chunks[i].length_dw = user_chunk.length_dw;
size = p->chunks[i].length_dw; size = p->chunks[i].length_dw;
cdata = (void __user *)(uintptr_t)user_chunk.chunk_data; cdata = u64_to_user_ptr(user_chunk.chunk_data);
p->chunks[i].kdata = kvmalloc_array(size, sizeof(uint32_t), GFP_KERNEL); p->chunks[i].kdata = kvmalloc_array(size, sizeof(uint32_t), GFP_KERNEL);
if (p->chunks[i].kdata == NULL) { if (p->chunks[i].kdata == NULL) {
...@@ -1437,7 +1437,7 @@ int amdgpu_cs_wait_fences_ioctl(struct drm_device *dev, void *data, ...@@ -1437,7 +1437,7 @@ int amdgpu_cs_wait_fences_ioctl(struct drm_device *dev, void *data,
if (fences == NULL) if (fences == NULL)
return -ENOMEM; return -ENOMEM;
fences_user = (void __user *)(uintptr_t)(wait->in.fences); fences_user = u64_to_user_ptr(wait->in.fences);
if (copy_from_user(fences, fences_user, if (copy_from_user(fences, fences_user,
sizeof(struct drm_amdgpu_fence) * fence_count)) { sizeof(struct drm_amdgpu_fence) * fence_count)) {
r = -EFAULT; r = -EFAULT;
......
...@@ -689,7 +689,7 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, ...@@ -689,7 +689,7 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data,
switch (args->op) { switch (args->op) {
case AMDGPU_GEM_OP_GET_GEM_CREATE_INFO: { case AMDGPU_GEM_OP_GET_GEM_CREATE_INFO: {
struct drm_amdgpu_gem_create_in info; struct drm_amdgpu_gem_create_in info;
void __user *out = (void __user *)(uintptr_t)args->value; void __user *out = u64_to_user_ptr(args->value);
info.bo_size = robj->gem_base.size; info.bo_size = robj->gem_base.size;
info.alignment = robj->tbo.mem.page_alignment << PAGE_SHIFT; info.alignment = robj->tbo.mem.page_alignment << PAGE_SHIFT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment