From: jsg Date: Thu, 24 Aug 2023 06:10:10 +0000 (+0000) Subject: drm/amdgpu: Fix potential fence use-after-free v2 X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=d62e2f46081d40b53750a85e515f085fa15f46b6;p=openbsd drm/amdgpu: Fix potential fence use-after-free v2 From shanzhulig dd0b3b367c3839e439f36af908b39c98929a5e54 in linux-6.1.y/6.1.47 2e54154b9f27262efd0cb4f903cc7d5ad1fe9628 in mainline linux --- 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));