Similar to the previous patch lets precede the fence->ops dereference with
the signaled check. This reduces the window to hit the race where sync
file can get into a signaled DRM scheduler fence which was left "dangling"
after the driver had potentially torn down the corresponding internal
state.

Signed-off-by: Tvrtko Ursulin <[email protected]>
Cc: Christian König <[email protected]>
Cc: Danilo Krummrich <[email protected]>
Cc: Lucas De Marchi <[email protected]>
Cc: Matthew Brost <[email protected]>
Cc: Philipp Stanner <[email protected]>
Cc: Rodrigo Vivi <[email protected]>
---
 drivers/dma-buf/dma-fence.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
index f0cdd3e99d36..b3f085a65910 100644
--- a/drivers/dma-buf/dma-fence.c
+++ b/drivers/dma-buf/dma-fence.c
@@ -968,7 +968,7 @@ EXPORT_SYMBOL(dma_fence_wait_any_timeout);
  */
 void dma_fence_set_deadline(struct dma_fence *fence, ktime_t deadline)
 {
-       if (fence->ops->set_deadline && !dma_fence_is_signaled(fence))
+       if (!dma_fence_is_signaled(fence) && fence->ops->set_deadline)
                fence->ops->set_deadline(fence, deadline);
 }
 EXPORT_SYMBOL(dma_fence_set_deadline);
-- 
2.48.0

Reply via email to