summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2020-02-12 15:07:59 +0300
committerAlex Deucher <alexander.deucher@amd.com>2020-02-12 16:04:41 -0500
commit434cbcb1bd5dea181e6e2379f9f4d4949b51d445 (patch)
tree6fe9206773f3b665865e2c534cd93708a961d6eb /drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
parent72b4c01d66951cff759799dc3000a692d8821b30 (diff)
drm/amdgpu: return -EFAULT if copy_to_user() fails
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") Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c6
1 files 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 431a47569acc..0b4c09b613a2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -2290,7 +2290,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;
@@ -2304,9 +2303,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;