Skip to contentSkip to conversation

media: coda: fix macroblocks count control usage

git:media_tree/fixes Mauro Carvalho Chehab 1 participant 1 message Mar 22, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

This is an automatic generated email to let you know that the following patch were queued:

Subject: media: coda: fix macroblocks count control usage
Author:  Marco Felsch <[email protected]>
Date:    Fri Mar 5 09:23:54 2021 +0100

Commit b2d3bef1aa78 ("media: coda: Add a V4L2 user for control error macroblocks count") add the control for the decoder devices. But during streamon() this ioctl gets called for all (encoder and decoder) devices and on encoder devices this causes a null pointer exception.

Fix this by setting the control only if it is really accessible.

Fixes b2d3bef1aa78 ("media: coda: Add a V4L2 user for control error macroblocks count")
 drivers/media/platform/coda/coda-common.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

---

drivers/media/platform/coda/coda-common.c +3 -1
index 995e95272e51..e600764dce96 100644
@@ -2062,7 +2062,9 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count)
 	if (q_data_dst->fourcc == V4L2_PIX_FMT_JPEG)
 		ctx->params.gop_size = 1;
 	ctx->gopcounter = ctx->params.gop_size - 1;
-	v4l2_ctrl_s_ctrl(ctx->mb_err_cnt_ctrl, 0);
+	/* Only decoders have this control */
+	if (ctx->mb_err_cnt_ctrl)
+		v4l2_ctrl_s_ctrl(ctx->mb_err_cnt_ctrl, 0);
 
 	ret = ctx->ops->start_streaming(ctx);
 	if (ctx->inst_type == CODA_INST_DECODER) {