media: mediatek: vcodec: Handle invalid encoder vsi
authorIrui Wang <irui.wang@mediatek.com>
Sat, 7 Oct 2023 11:33:47 +0000 (19:33 +0800)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Fri, 13 Oct 2023 09:33:22 +0000 (11:33 +0200)
Handle invalid encoder vsi in vpu_enc_init to ensure the encoder
vsi is valid for future use.

Fixes: 1972e32431ed ("media: mediatek: vcodec: Fix possible invalid memory access for encoder")
Signed-off-by: Irui Wang <irui.wang@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/platform/mediatek/vcodec/encoder/venc_vpu_if.c

index d299cc2962a5ae0eb84e8115c3cf364789d1e4c6..39e8f3ac53ca63703075faeefd9863c5a9758996 100644 (file)
@@ -153,6 +153,11 @@ int vpu_enc_init(struct venc_vpu_inst *vpu)
                return -EINVAL;
        }
 
+       if (IS_ERR_OR_NULL(vpu->vsi)) {
+               mtk_venc_err(vpu->ctx, "invalid venc vsi");
+               return -EINVAL;
+       }
+
        return 0;
 }