diff mbox series

dma-buf: fix dma_fence_default_wait() signaling check

Message ID 20220919120618.113332-1-christian.koenig@amd.com (mailing list archive)
State New, archived
Headers show
Series dma-buf: fix dma_fence_default_wait() signaling check | expand

Commit Message

Christian König Sept. 19, 2022, 12:06 p.m. UTC
That check must now come after grabing the spinlock, not before.

Signed-off-by: Christian König <christian.koenig@amd.com>
Fixes: b96fb1e724ae ("dma-buf: dma_fence_wait must enable signaling")
---
 drivers/dma-buf/dma-fence.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

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

Acked-by: Alex Deucher <alexander.deucher@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
>
diff mbox series

Patch

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;