Skip to content

Commit 64cc12f

Browse files
Dan Carpenteralexdeucher
authored andcommitted
drm/amdgpu: Fix error codes if copy_to_user() fails
The copy_to_user() function returns the number of bytes that it wasn't able to copy, but we should return -EFAULT to the user. Fixes: 4d82724 ("drm/amdgpu: Add mapping info option for GEM_OP ioctl") Fixes: f9db1fc ("drm/amdgpu: Add ioctl to get all gem handles for a process") Reviewed-By: David Francis <David.Francis@amd.com> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent b7c5334 commit 64cc12f

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,8 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data,
10661066
drm_exec_fini(&exec);
10671067

10681068
if (num_mappings > 0 && num_mappings <= args->num_entries)
1069-
r = copy_to_user(u64_to_user_ptr(args->value), vm_entries, num_mappings * sizeof(*vm_entries));
1069+
if (copy_to_user(u64_to_user_ptr(args->value), vm_entries, num_mappings * sizeof(*vm_entries)))
1070+
r = -EFAULT;
10701071

10711072
args->num_entries = num_mappings;
10721073

@@ -1158,7 +1159,8 @@ int amdgpu_gem_list_handles_ioctl(struct drm_device *dev, void *data,
11581159
args->num_entries = bo_index;
11591160

11601161
if (!ret)
1161-
ret = copy_to_user(u64_to_user_ptr(args->entries), bo_entries, num_bos * sizeof(*bo_entries));
1162+
if (copy_to_user(u64_to_user_ptr(args->entries), bo_entries, num_bos * sizeof(*bo_entries)))
1163+
ret = -EFAULT;
11621164

11631165
kvfree(bo_entries);
11641166

0 commit comments

Comments
 (0)