From: Tom St Denis Date: Tue, 23 May 2017 15:35:22 +0000 (-0400) Subject: drm/amd/amdgpu: Return error if initiating read out of range on vram X-Git-Tag: C0P2-H0.0--20200415~8073 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=b85007c9114a05c696c46c2aac6da68aeaed7bbc;p=linux.git drm/amd/amdgpu: Return error if initiating read out of range on vram commit 9156e723301c0a7a7def4cde820e018ce791b842 upstream. If you initiate a read that is out of the VRAM address space return ENXIO instead of 0. Reads that begin below that point will read upto the VRAM limit as before. Signed-off-by: Tom St Denis Reviewed-by: Christian König Signed-off-by: Alex Deucher Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index dcaf691f56b5..264899df9bfc 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -1419,6 +1419,9 @@ static ssize_t amdgpu_ttm_vram_read(struct file *f, char __user *buf, if (size & 0x3 || *pos & 0x3) return -EINVAL; + if (*pos >= adev->mc.mc_vram_size) + return -ENXIO; + while (size) { unsigned long flags; uint32_t value;