[PATCH] drm/amdgpu: return -EFAULT if copy_to_user() fails
Christian König
christian.koenig at amd.com
Wed Feb 12 12:12:17 UTC 2020
Am 12.02.20 um 13:07 schrieb Dan Carpenter:
> The copy_to_user() function returns the number of bytes remaining to be
> copied, but we want to return a negative error code to the user.
>
> Fixes: 030d5b97a54b ("drm/amdgpu: use amdgpu_device_vram_access in amdgpu_ttm_vram_read")
> Signed-off-by: Dan Carpenter <dan.carpenter at oracle.com>
Reviewed-by: Christian König <christian.koenig at amd.com>
Alex do you want to pick that up or should I do this?
Thanks,
Christian.
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index 15f5451d312d..660867cf2597 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -2280,7 +2280,6 @@ static ssize_t amdgpu_ttm_vram_read(struct file *f, char __user *buf,
> {
> struct amdgpu_device *adev = file_inode(f)->i_private;
> ssize_t result = 0;
> - int r;
>
> if (size & 0x3 || *pos & 0x3)
> return -EINVAL;
> @@ -2294,9 +2293,8 @@ static ssize_t amdgpu_ttm_vram_read(struct file *f, char __user *buf,
> uint32_t value[AMDGPU_TTM_VRAM_MAX_DW_READ];
>
> amdgpu_device_vram_access(adev, *pos, value, bytes, false);
> - r = copy_to_user(buf, value, bytes);
> - if (r)
> - return r;
> + if (copy_to_user(buf, value, bytes))
> + return -EFAULT;
>
> result += bytes;
> buf += bytes;
More information about the amd-gfx
mailing list