diff mbox series

[v7,3/5] media: mediatek: vcodec: remove media request checking

Message ID 20241116031724.15694-4-yunfei.dong@mediatek.com (mailing list archive)
State New
Headers show
Series media: mediatek: vcodec: fix v4l2_ctrl_request_complete fail | expand

Commit Message

Yunfei Dong Nov. 16, 2024, 3:17 a.m. UTC
Setting the buffer status to error if the media request of
each source buffer is NULL, then schedule the work to process
again in case of access NULL pointer.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
---
 .../mediatek/vcodec/decoder/mtk_vcodec_dec.c    |  6 ++----
 .../vcodec/decoder/mtk_vcodec_dec_stateless.c   | 17 +++++------------
 2 files changed, 7 insertions(+), 16 deletions(-)
diff mbox series

Patch

diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c
index 2ccdffbadcda..b16572d5cf54 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c
+++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c
@@ -912,10 +912,8 @@  void vb2ops_vdec_stop_streaming(struct vb2_queue *q)
 					src_buf->vb2_buf.req_obj.req;
 
 				v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_ERROR);
-				if (req) {
-					v4l2_ctrl_request_complete(req, &ctx->ctrl_hdl);
-					media_request_manual_complete(req);
-				}
+				v4l2_ctrl_request_complete(req, &ctx->ctrl_hdl);
+				media_request_manual_complete(req);
 			}
 		}
 		return;
diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c
index 1e11c08d708f..dd6ee694382e 100644
--- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c
+++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c
@@ -264,10 +264,8 @@  static void mtk_vdec_stateless_cap_to_disp(struct mtk_vcodec_dec_ctx *ctx, int e
 		mtk_v4l2_vdec_err(ctx, "dst buffer is NULL");
 	}
 
-	if (src_buf_req) {
-		v4l2_ctrl_request_complete(src_buf_req, &ctx->ctrl_hdl);
-		media_request_manual_complete(src_buf_req);
-	}
+	v4l2_ctrl_request_complete(src_buf_req, &ctx->ctrl_hdl);
+	media_request_manual_complete(src_buf_req);
 }
 
 static struct vdec_fb *vdec_get_cap_buffer(struct mtk_vcodec_dec_ctx *ctx)
@@ -356,10 +354,7 @@  static void mtk_vdec_worker(struct work_struct *work)
 			  ctx->id, bs_src->va, &bs_src->dma_addr, bs_src->size, vb2_src);
 	/* Apply request controls. */
 	src_buf_req = vb2_src->req_obj.req;
-	if (src_buf_req)
-		v4l2_ctrl_request_setup(src_buf_req, &ctx->ctrl_hdl);
-	else
-		mtk_v4l2_vdec_err(ctx, "vb2 buffer media request is NULL");
+	v4l2_ctrl_request_setup(src_buf_req, &ctx->ctrl_hdl);
 
 	ret = vdec_if_decode(ctx, bs_src, NULL, &res_chg);
 	if (ret && ret != -EAGAIN) {
@@ -378,10 +373,8 @@  static void mtk_vdec_worker(struct work_struct *work)
 	if (!IS_VDEC_LAT_ARCH(dev->vdec_pdata->hw_arch) ||
 	    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);
-			media_request_manual_complete(src_buf_req);
-		}
+		v4l2_ctrl_request_complete(src_buf_req, &ctx->ctrl_hdl);
+		media_request_manual_complete(src_buf_req);
 	} else {
 		if (ret != -EAGAIN) {
 			v4l2_m2m_src_buf_remove(ctx->m2m_ctx);