drm/amdgpu: fix signed overrun in amdgpu_ctx_get_fence
authorChristian König <christian.koenig@amd.com>
Sat, 18 Jul 2015 17:20:05 +0000 (19:20 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 17 Aug 2015 20:50:15 +0000 (16:50 -0400)
Otherwise the first 16 fences of a context will always signal immediately.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c

index 859a4841075e74e26ffd36cdafb5117fb3b17af1..144edc97c6fedf6e6eecb318ffc53f90f7139304 100644 (file)
@@ -226,7 +226,7 @@ struct fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx,
                return ERR_PTR(-EINVAL);
        }
 
-       if (seq < cring->sequence - AMDGPU_CTX_MAX_CS_PENDING) {
+       if (seq + AMDGPU_CTX_MAX_CS_PENDING < cring->sequence) {
                spin_unlock(&ctx->ring_lock);
                return NULL;
        }