media: mediatek: vcodec: Handle invalid decoder vsi
authorIrui Wang <irui.wang@mediatek.com>
Thu, 21 Mar 2024 01:47:54 +0000 (09:47 +0800)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Mon, 10 Jun 2024 08:24:11 +0000 (10:24 +0200)
Handle an invalid decoder vsi in vpu_dec_init to ensure the decoder vsi
is valid for future use.

Fixes: 590577a4e525 ("[media] vcodec: mediatek: Add Mediatek V4L2 Video Decoder Driver")

Signed-off-by: Irui Wang <irui.wang@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c

index da6be556727bb18a458e1e59235615dc9b42c05f..145958206e38a4be1d8f4cccc331cde82f5f4e27 100644 (file)
@@ -233,6 +233,12 @@ int vpu_dec_init(struct vdec_vpu_inst *vpu)
        mtk_vdec_debug(vpu->ctx, "vdec_inst=%p", vpu);
 
        err = vcodec_vpu_send_msg(vpu, (void *)&msg, sizeof(msg));
+
+       if (IS_ERR_OR_NULL(vpu->vsi)) {
+               mtk_vdec_err(vpu->ctx, "invalid vdec vsi, status=%d", err);
+               return -EINVAL;
+       }
+
        mtk_vdec_debug(vpu->ctx, "- ret=%d", err);
        return err;
 }