drm/amdgpu: fix error handling in amdgpu_cs_process_fence_dep
We always need to drop the ctx reference and should check for errors first and then dereference the fence pointer. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Chunming Zhou <david1.zhou@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
f0bc1ee473
commit
67d0859e27
|
@ -1044,29 +1044,27 @@ static int amdgpu_cs_process_fence_dep(struct amdgpu_cs_parser *p,
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
fence = amdgpu_ctx_get_fence(ctx, entity,
|
fence = amdgpu_ctx_get_fence(ctx, entity, deps[i].handle);
|
||||||
deps[i].handle);
|
amdgpu_ctx_put(ctx);
|
||||||
|
|
||||||
|
if (IS_ERR(fence))
|
||||||
|
return PTR_ERR(fence);
|
||||||
|
else if (!fence)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (chunk->chunk_id == AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES) {
|
if (chunk->chunk_id == AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES) {
|
||||||
struct drm_sched_fence *s_fence = to_drm_sched_fence(fence);
|
struct drm_sched_fence *s_fence;
|
||||||
struct dma_fence *old = fence;
|
struct dma_fence *old = fence;
|
||||||
|
|
||||||
|
s_fence = to_drm_sched_fence(fence);
|
||||||
fence = dma_fence_get(&s_fence->scheduled);
|
fence = dma_fence_get(&s_fence->scheduled);
|
||||||
dma_fence_put(old);
|
dma_fence_put(old);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_ERR(fence)) {
|
r = amdgpu_sync_fence(p->adev, &p->job->sync, fence, true);
|
||||||
r = PTR_ERR(fence);
|
dma_fence_put(fence);
|
||||||
amdgpu_ctx_put(ctx);
|
if (r)
|
||||||
return r;
|
return r;
|
||||||
} else if (fence) {
|
|
||||||
r = amdgpu_sync_fence(p->adev, &p->job->sync, fence,
|
|
||||||
true);
|
|
||||||
dma_fence_put(fence);
|
|
||||||
amdgpu_ctx_put(ctx);
|
|
||||||
if (r)
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue