This is a note to let you know that I've just added the patch titled media: venus: fix enc/dec destruction order to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: media-venus-fix-enc-dec-destruction-order.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit d217789c5fcd7ae66a544f5d9d54db8d1b5084b4 Author: Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx> Date: Sat Oct 26 01:56:41 2024 +0900 media: venus: fix enc/dec destruction order [ Upstream commit 6c9934c5a00ae722a98d1a06ed44b673514407b5 ] We destroy mutex-es too early as they are still taken in v4l2_fh_exit()->v4l2_event_unsubscribe()->v4l2_ctrl_find(). We should destroy mutex-es right before kfree(). Also do not vdec_ctrl_deinit() before v4l2_fh_exit(). Fixes: 7472c1c69138 ("[media] media: venus: vdec: add video decoder files") Suggested-by: Tomasz Figa <tfiga@xxxxxxxxxx> Signed-off-by: Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx> Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@xxxxxxxxxx> Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@xxxxxxxxx> Signed-off-by: Hans Verkuil <hverkuil@xxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 3cb8a284fc68f..af7352ce13990 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -1642,13 +1642,14 @@ static int vdec_close(struct file *file) cancel_work_sync(&inst->delayed_process_work); v4l2_m2m_ctx_release(inst->m2m_ctx); v4l2_m2m_release(inst->m2m_dev); - vdec_ctrl_deinit(inst); ida_destroy(&inst->dpb_ids); hfi_session_destroy(inst); - mutex_destroy(&inst->lock); - mutex_destroy(&inst->ctx_q_lock); v4l2_fh_del(&inst->fh); v4l2_fh_exit(&inst->fh); + vdec_ctrl_deinit(inst); + + mutex_destroy(&inst->lock); + mutex_destroy(&inst->ctx_q_lock); vdec_pm_put(inst, false); diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 4a439b4908ea7..c833ca05cd9ec 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -1471,14 +1471,14 @@ static int venc_close(struct file *file) v4l2_m2m_ctx_release(inst->m2m_ctx); v4l2_m2m_release(inst->m2m_dev); - venc_ctrl_deinit(inst); hfi_session_destroy(inst); - mutex_destroy(&inst->lock); - mutex_destroy(&inst->ctx_q_lock); v4l2_fh_del(&inst->fh); v4l2_fh_exit(&inst->fh); + venc_ctrl_deinit(inst); inst->enc_state = VENUS_ENC_STATE_DEINIT; + mutex_destroy(&inst->lock); + mutex_destroy(&inst->ctx_q_lock); venc_pm_put(inst, false);