Touching bo->resource looks like it should require first locking the
object, since this state is dynamic and could potentially change from
under us. It looks we can just use obj->base.size here, which avoids any
issues with locking, since this is immutable state.

Signed-off-by: Matthew Auld <[email protected]>
Cc: Christian König <[email protected]>
Reviewed-by: Christian König <[email protected]>
---
 drivers/gpu/drm/ttm/ttm_bo_vm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index 38119311284d..e0f73f0ac086 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -412,7 +412,7 @@ int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned 
long addr,
                 << PAGE_SHIFT);
        int ret;
 
-       if (len < 1 || (offset + len) >> PAGE_SHIFT > bo->resource->num_pages)
+       if (len < 1 || (offset + len) > bo->base.size)
                return -EIO;
 
        ret = ttm_bo_reserve(bo, true, false, NULL);
-- 
2.37.3

Reply via email to