diff options
| author | Dan Carpenter <dan.carpenter@linaro.org> | 2025-09-04 21:58:49 +0300 |
|---|---|---|
| committer | Alex Deucher <alexander.deucher@amd.com> | 2025-09-05 17:38:42 -0400 |
| commit | 64cc12f9798f146f2c616db4885d653741d3b3c1 (patch) | |
| tree | 3ab8c98d5d49ea4b3587319d255ce6c93747c354 /drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | |
| parent | b7c5334af69d359fcd7a39ed409a08138900ec18 (diff) | |
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: 4d82724f7f2b ("drm/amdgpu: Add mapping info option for GEM_OP ioctl")
Fixes: f9db1fc52ceb ("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>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c')
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c index 8bec41cdccd7..630175746780 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c @@ -1066,7 +1066,8 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, drm_exec_fini(&exec); if (num_mappings > 0 && num_mappings <= args->num_entries) - r = copy_to_user(u64_to_user_ptr(args->value), vm_entries, num_mappings * sizeof(*vm_entries)); + if (copy_to_user(u64_to_user_ptr(args->value), vm_entries, num_mappings * sizeof(*vm_entries))) + r = -EFAULT; args->num_entries = num_mappings; @@ -1158,7 +1159,8 @@ int amdgpu_gem_list_handles_ioctl(struct drm_device *dev, void *data, args->num_entries = bo_index; if (!ret) - ret = copy_to_user(u64_to_user_ptr(args->entries), bo_entries, num_bos * sizeof(*bo_entries)); + if (copy_to_user(u64_to_user_ptr(args->entries), bo_entries, num_bos * sizeof(*bo_entries))) + ret = -EFAULT; kvfree(bo_entries); |