[PATCH] dma-buf: fix dma_fence_default_wait() signaling check

Alex Deucher alexdeucher at gmail.com
Mon Sep 19 13:18:06 UTC 2022


On Mon, Sep 19, 2022 at 8:06 AM Christian König
<ckoenig.leichtzumerken at gmail.com> wrote:
>
> That check must now come after grabing the spinlock, not before.
>
> Signed-off-by: Christian König <christian.koenig at amd.com>
> Fixes: b96fb1e724ae ("dma-buf: dma_fence_wait must enable signaling")

Acked-by: Alex Deucher <alexander.deucher at amd.com>

> ---
>  drivers/dma-buf/dma-fence.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
> index a5fbf1c1e0ea..406b4e26f538 100644
> --- a/drivers/dma-buf/dma-fence.c
> +++ b/drivers/dma-buf/dma-fence.c
> @@ -763,11 +763,11 @@ dma_fence_default_wait(struct dma_fence *fence, bool intr, signed long timeout)
>         unsigned long flags;
>         signed long ret = timeout ? timeout : 1;
>
> -       if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
> -               return ret;
> -
>         spin_lock_irqsave(fence->lock, flags);
>
> +       if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
> +               goto out;
> +
>         if (intr && signal_pending(current)) {
>                 ret = -ERESTARTSYS;
>                 goto out;
> --
> 2.25.1
>


More information about the dri-devel mailing list