From d62e2f46081d40b53750a85e515f085fa15f46b6 Mon Sep 17 00:00:00 2001 From: jsg Date: Thu, 24 Aug 2023 06:10:10 +0000 Subject: [PATCH] drm/amdgpu: Fix potential fence use-after-free v2 From shanzhulig dd0b3b367c3839e439f36af908b39c98929a5e54 in linux-6.1.y/6.1.47 2e54154b9f27262efd0cb4f903cc7d5ad1fe9628 in mainline linux --- sys/dev/pci/drm/amd/amdgpu/amdgpu_cs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_cs.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_cs.c index 22f8a5a610e..0508926871a 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_cs.c +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_cs.c @@ -1609,15 +1609,15 @@ static int amdgpu_cs_wait_all_fences(struct amdgpu_device *adev, continue; r = dma_fence_wait_timeout(fence, true, timeout); + if (r > 0 && fence->error) + r = fence->error; + dma_fence_put(fence); if (r < 0) return r; if (r == 0) break; - - if (fence->error) - return fence->error; } memset(wait, 0, sizeof(*wait)); -- 2.20.1