media: mediatek: vcodec: Can't set dst buffer to done when lat decode error
authorYunfei Dong <yunfei.dong@mediatek.com>
Thu, 17 Nov 2022 09:24:50 +0000 (09:24 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:33:03 +0000 (13:33 +0100)
[ Upstream commit 3568ecd3f3a6d133ab7feffbba34955c8c79bbc4 ]

Core thread will call v4l2_m2m_buf_done to set dst buffer done for
lat architecture. If lat call v4l2_m2m_buf_done_and_job_finish to
free dst buffer when lat decode error, core thread will access kernel
NULL pointer dereference, then crash.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_stateless.c

index e868090..ffbcee0 100644 (file)
@@ -253,7 +253,7 @@ static void mtk_vdec_worker(struct work_struct *work)
 
        state = ret ? VB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE;
        if (!IS_VDEC_LAT_ARCH(dev->vdec_pdata->hw_arch) ||
-           ctx->current_codec == V4L2_PIX_FMT_VP8_FRAME || ret) {
+           ctx->current_codec == V4L2_PIX_FMT_VP8_FRAME) {
                v4l2_m2m_buf_done_and_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx, state);
                if (src_buf_req)
                        v4l2_ctrl_request_complete(src_buf_req, &ctx->ctrl_hdl);