The page range should be checked for the critical region.

Signed-off-by: Xiang Liu <xiang....@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
index c9df026e53f7..db7fd21b2c04 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
@@ -406,15 +406,18 @@ int amdgpu_vram_mgr_query_address_block_info(struct 
amdgpu_vram_mgr *mgr,
 {
        struct amdgpu_vram_mgr_resource *vres;
        struct drm_buddy_block *block;
-       u64 start, size;
+       u64 start, size, addr_begin, addr_end;
        int ret = -ENOENT;
 
+       addr_begin = address & PAGE_MASK;
+       addr_end = address | (PAGE_SIZE - 1);
+
        mutex_lock(&mgr->lock);
        list_for_each_entry(vres, &mgr->allocated_vres_list, vres_node) {
                list_for_each_entry(block, &vres->blocks, link) {
                        start = amdgpu_vram_mgr_block_start(block);
                        size = amdgpu_vram_mgr_block_size(block);
-                       if ((start <= address) && (address < (start + size))) {
+                       if ((start <= addr_begin) && (addr_end < (start + 
size))) {
                                info->start = start;
                                info->size = size;
                                memcpy(&info->task, &vres->task, 
sizeof(vres->task));
-- 
2.34.1

Reply via email to