Skip to contentSkip to conversation

drm/amdgpu: Fix UserQ fence iterator cleanup

PATCH In review Erhan Bilgili 2 participants 2 messages Nov 13

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: Fix UserQ fence iterator cleanup

If a fallback wait is interrupted, USERQ_WAIT leaves the unwrap loop without releasing the reference taken by dma_fence_unwrap_first(). That reference is normally dropped by dma_fence_chain_walk().

Drop iter.chain before returning the error.

Fixes 15e30a6e4792 ("drm/amdgpu: Add wait IOCTL timeline syncobj support")
---
 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
index dd976a50e053..e7b63c227421 100644
@@ -796,6 +796,7 @@ amdgpu_userq_wait_return_fence_info(struct drm_device *dev, struct drm_file *fil
 			r = amdgpu_userq_wait_add_fence(wait_info, fences,
 							&num_fences, f);
 			if (r) {
+				dma_fence_put(iter.chain);
 				dma_fence_put(fence);
 				goto free_fences;
 			}
Signature · 1 line
2.56.1
maintainer
#1 lore raw
Quoted 8 lines · Erhan Bilgili

If a fallback wait is interrupted, USERQ_WAIT leaves the unwrap loop without releasing the reference taken by dma_fence_unwrap_first(). That reference is normally dropped by dma_fence_chain_walk().

Drop iter.chain before returning the error.

Fixes 15e30a6e4792 ("drm/amdgpu: Add wait IOCTL timeline syncobj support")

Good catch, but we should probably fix dma_fence_unwrap() instead and add a cleanup.

I will take care of that.

Regards,
Christian.

Quoted 16 lines
---
 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
index dd976a50e053..e7b63c227421 100644
@@ -796,6 +796,7 @@ amdgpu_userq_wait_return_fence_info(struct drm_device *dev, struct drm_file *fil
 			r = amdgpu_userq_wait_add_fence(wait_info, fences,
 							&num_fences, f);
 			if (r) {
+				dma_fence_put(iter.chain);
 				dma_fence_put(fence);
 				goto free_fences;
 			}