From fd1c39b0a38eb6b39237384e8bacded6fb043708 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 4 Aug 2021 21:10:57 -0700 Subject: [PATCH] vkr: fix a potential deadlock in vkr_context_submit_cmd Fixes: 0432a54 ("vkr: check decoder status before decoding") Signed-off-by: Chia-I Wu Reviewed-by: Yiwei Zhang --- src/venus/vkr_context.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/venus/vkr_context.c b/src/venus/vkr_context.c index 9e0795a..6145136 100644 --- a/src/venus/vkr_context.c +++ b/src/venus/vkr_context.c @@ -200,8 +200,10 @@ vkr_context_submit_cmd(struct virgl_context *base, const void *buffer, size_t si mtx_lock(&ctx->mutex); /* CS error is considered fatal (destroy the context?) */ - if (vkr_cs_decoder_get_fatal(&ctx->decoder)) + if (vkr_cs_decoder_get_fatal(&ctx->decoder)) { + mtx_unlock(&ctx->mutex); return EINVAL; + } vkr_cs_decoder_set_stream(&ctx->decoder, buffer, size);