drm/amdgpu: consistent use u64_to_user_ptr
authorChristian König <christian.koenig@amd.com>
Wed, 26 Jul 2017 15:02:52 +0000 (17:02 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 15 Aug 2017 18:45:53 +0000 (14:45 -0400)
Instead of open coding the conversion from u64 to pointers.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c

index d324e1c240280d23ae26455cfb321561b0cf0494..ccd7697792ab46d40fcd6e259b9b8088106fc262 100644 (file)
@@ -270,7 +270,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,
        struct amdgpu_fpriv *fpriv = filp->driver_priv;
        union drm_amdgpu_bo_list *args = data;
        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 amdgpu_bo_list *list;
index 33789510e663f96594468e0eab258ff62d524f0b..381b4f99648d1caceb0875e206a9dcfe75df4d1c 100644 (file)
@@ -90,7 +90,7 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data)
        }
 
        /* 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,
                           sizeof(uint64_t)*cs->in.num_chunks)) {
                ret = -EFAULT;
@@ -110,7 +110,7 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data)
                struct drm_amdgpu_cs_chunk user_chunk;
                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,
                                       sizeof(struct drm_amdgpu_cs_chunk))) {
                        ret = -EFAULT;
@@ -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;
 
                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);
                if (p->chunks[i].kdata == NULL) {
@@ -1437,7 +1437,7 @@ int amdgpu_cs_wait_fences_ioctl(struct drm_device *dev, void *data,
        if (fences == NULL)
                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,
                sizeof(struct drm_amdgpu_fence) * fence_count)) {
                r = -EFAULT;
index 917ac5e074a00e0ac4c5b408676298def1e4d06d..88085e7f72de10781e470a038c3362c2b348647c 100644 (file)
@@ -689,7 +689,7 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data,
        switch (args->op) {
        case AMDGPU_GEM_OP_GET_GEM_CREATE_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.alignment = robj->tbo.mem.page_alignment << PAGE_SHIFT;