drm/amd/amdgpu: fix offset into page with amdgpu_iomem debugfs file
authorTom St Denis <tom.stdenis@amd.com>
Tue, 20 Mar 2018 13:13:08 +0000 (09:13 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 21 Mar 2018 04:43:34 +0000 (23:43 -0500)
The offset inside the page wasn't included in the copy call meaning
the start of the page was being read/written instead.

Reported-by: Jay Cornwall <Jay.Cornwall@amd.com>
Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

index e28b73609fbc1366e7078fc4a4f28f0ba431e67c..205da3ff9cd0436b36a414f092297ad7f7ea40f0 100644 (file)
@@ -2021,7 +2021,7 @@ static ssize_t amdgpu_iomem_read(struct file *f, char __user *buf,
                        return -EPERM;
 
                ptr = kmap(p);
-               r = copy_to_user(buf, ptr, bytes);
+               r = copy_to_user(buf, ptr + off, bytes);
                kunmap(p);
                if (r)
                        return -EFAULT;
@@ -2065,7 +2065,7 @@ static ssize_t amdgpu_iomem_write(struct file *f, const char __user *buf,
                        return -EPERM;
 
                ptr = kmap(p);
-               r = copy_from_user(ptr, buf, bytes);
+               r = copy_from_user(ptr + off, buf, bytes);
                kunmap(p);
                if (r)
                        return -EFAULT;