]> git.hungrycats.org Git - linux/commitdiff
drm/amd/amdgpu: Return error if initiating read out of range on vram
authorTom St Denis <tom.stdenis@amd.com>
Tue, 23 May 2017 15:35:22 +0000 (11:35 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jul 2017 22:06:06 +0000 (15:06 -0700)
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 <tom.stdenis@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

index 475c38fe92453d36899c75c01dc09a461e5f7dca..e40a6d8b0b92813a6d91a83cb46726c37e0dacd5 100644 (file)
@@ -1126,6 +1126,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;