drm/amdgpu/userq: check NULL pointer
Subsystems (2)
PATCH 1/1 drm/amdgpu/userq: check NULL pointer
bo could be NULL in the vm->done list and the
access of it must be avoided.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1 -1
@@ -943,7 +943,7 @@ amdgpu_userq_vm_validate(struct amdgpu_userq_mgr *uq_mgr)list_for_each_entry (bo_va, &vm->done, base.vm_status) { bo = bo_va->base.bo; -if (!amdgpu_ttm_tt_is_userptr (bo->tbo.ttm)) +if (!bo || !amdgpu_ttm_tt_is_userptr (bo->tbo.ttm))continue ; range =xa_load (&xa, key);
Signature · 1 line
2.43.0
PATCH 1/1 drm/amdgpu/userq: need to unref bo
unref bo after amdgpu_bo_unreserve() failure as it has called amdgpu_bo_ref() already
--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +1 -0
@@ -386,6 +386,7 @@ static int amdgpu_userq_fence_read_wptr(struct amdgpu_usermode_queue *queue,amdgpu_bo_unreserve (queue->vm->root.bo); r =amdgpu_bo_reserve (bo, true);if (r) { +amdgpu_bo_unref (&bo);DRM_ERROR ("Failed to reserve userqueue wptr bo" );return r; }
Signature · 1 line
2.43.0
Re: [PATCH] drm/amdgpu/userq: need to unref bo
Quoted 3 lines · David (Ming Qiang) Wu
unref bo after
amdgpu_bo_unreserve()failure as it has calledamdgpu_bo_ref()already
The other error paths need to be fixed as well.
Alex
Quoted 21 lines
Signed-off-by David (Ming Qiang) Wu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +1
-1@@ -386,6 +386,7 @@ static int amdgpu_userq_fence_read_wptr(struct amdgpu_usermode_queue *queue,amdgpu_bo_unreserve (queue->vm->root.bo); r =amdgpu_bo_reserve (bo, true);if (r) { +amdgpu_bo_unref (&bo);DRM_ERROR ("Failed to reserve userqueue wptr bo" );return r; } --2.43.0
Re: [PATCH] drm/amdgpu/userq: need to unref bo
Quoted 4 lines · Alex Deucher
Quoted 2 lines · David (Ming Qiang) Wu
unref bo after
amdgpu_bo_unreserve()failure as it has calledamdgpu_bo_ref()alreadyThe other error paths need to be fixed as well.
hmm... do you mean "map_error"? it has the amdgpu_bo_unref() already.
David
Quoted 22 lines
Alex
Quoted 20 lines
Signed-off-by David (Ming Qiang) Wu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +1
-1@@ -386,6 +386,7 @@ static int amdgpu_userq_fence_read_wptr(struct amdgpu_usermode_queue *queue,amdgpu_bo_unreserve (queue->vm->root.bo); r =amdgpu_bo_reserve (bo, true);if (r) { +amdgpu_bo_unref (&bo);DRM_ERROR ("Failed to reserve userqueue wptr bo" );return r; } --2.43.0
Alex Deucher
Reviewed-byRe: [PATCH] drm/amdgpu/userq: need to unref bo
Quoted 8 lines · David Wu
Quoted 4 lines · Alex Deucher
Quoted 2 lines · David (Ming Qiang) Wu
unref bo after
amdgpu_bo_unreserve()failure as it has calledamdgpu_bo_ref()alreadyThe other error paths need to be fixed as well.
hmm... do you mean "
map_error"? it has theamdgpu_bo_unref()already.
whoops, yes, sorry.
Quoted 25 lines
David
Quoted 22 lines
Alex
Quoted 20 lines
Signed-off-by David (Ming Qiang) Wu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +1
-1@@ -386,6 +386,7 @@ static int amdgpu_userq_fence_read_wptr(struct amdgpu_usermode_queue *queue,amdgpu_bo_unreserve (queue->vm->root.bo); r =amdgpu_bo_reserve (bo, true);if (r) { +amdgpu_bo_unref (&bo);DRM_ERROR ("Failed to reserve userqueue wptr bo" );return r; } --2.43.0
Re: [PATCH] drm/amdgpu/userq: need to unref bo
no worries - also fix the typo ( amdgpu_bo_unreserve -> amdgpu_bo_reserve). Thanks for review.
David
Quoted 35 lines · Alex Deucher
Quoted 6 lines · David Wu
Quoted 4 lines · Alex Deucher
Quoted 2 lines · David (Ming Qiang) Wu
unref bo after
amdgpu_bo_unreserve()failure as it has calledamdgpu_bo_ref()alreadyThe other error paths need to be fixed as well.
hmm... do you mean "
map_error"? it has theamdgpu_bo_unref()already.whoops, yes, sorry.
Reviewed-by Alex Deucher<[email protected]>Quoted 24 lines
David
Quoted 22 lines
Alex
Quoted 20 lines
Signed-off-by David (Ming Qiang) Wu<[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +1
-1@@ -386,6 +386,7 @@ static int amdgpu_userq_fence_read_wptr(struct amdgpu_usermode_queue *queue,amdgpu_bo_unreserve (queue->vm->root.bo); r =amdgpu_bo_reserve (bo, true);if (r) { +amdgpu_bo_unref (&bo);DRM_ERROR ("Failed to reserve userqueue wptr bo" );return r; } --2.43.0
Quoted 5 lines · David (Ming Qiang) Wu
bo could be NULL in the
vm->donelist and the
access of it must be avoided.Signed-off-by David (Ming Qiang) Wu <[email protected]>
Sunil already fixed this in:
commit b15e3cc46803daf49625ab3289d103c437310ec3
Author: Sunil Khatri <[email protected]> Date: Fri Oct 31 14:10:13 2025 +0530
drm/amdgpu: validate the bo from done list for NULL
Make sure the bo is valid before using it.
Quoted 20 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1
-2@@ -943,7 +943,7 @@ amdgpu_userq_vm_validate(struct amdgpu_userq_mgr *uq_mgr)list_for_each_entry (bo_va, &vm->done, base.vm_status) { bo = bo_va->base.bo; -if (!amdgpu_ttm_tt_is_userptr (bo->tbo.ttm)) +if (!bo || !amdgpu_ttm_tt_is_userptr (bo->tbo.ttm))continue ; range =xa_load (&xa, key); --2.43.0