Skip to contentSkip to conversation

media: mediatek: vcodec: Handle invalid decoder vsi

PATCH Superseded Irui Wang 3 participants 5 messages Mar 20, 2024 – Mar 23, 2024

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Irui Wang

author
#0 lore raw

PATCH 1/1 media: mediatek: vcodec: Handle invalid decoder vsi

Handle invalid decoder vsi in vpu_dec_init to ensure the decoder vsi is valid for future use.

---
 .../media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c    | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c +6 -0
index 82e57ae983d5..17770993fe5a 100644
@@ -231,6 +231,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;
 }
Signature · 1 line
2.18.0
#1 lore raw

Il 20/03/24 07:13, Irui Wang ha scritto:

Quoted 4 lines

Handle invalid decoder vsi in vpu_dec_init to ensure the decoder vsi is valid for future use.

This commit needs a Fixes tag, can you please add the relevant one and resend?

Thanks,
Angelo

Quoted 21 lines
---
  .../media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c    | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c +6 -0
index 82e57ae983d5..17770993fe5a 100644
@@ -231,6 +231,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;
  }
#2 lore raw

Dear Angelo,

Thanks for your reviewing, patch v2 has been sent with 'Fixes' tag, thank you very much.

Best Regards

Quoted 40 lines · AngeloGioacchino Del Regno

Il 20/03/24 07:13, Irui Wang ha scritto:

Quoted 5 lines

Handle invalid decoder vsi in vpu_dec_init to ensure the decoder vsi is
valid for future use.

This commit needs a Fixes tag, can you please add the relevant one and resend?

Thanks,
Angelo

Quoted 25 lines
---
  .../media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c    | 6
++++++
  1 file changed, 6 insertions(+)

diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c index 82e57ae983d5..17770993fe5a 100644

drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c +6 -0
@@ -231,6 +231,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;
  }
#3 lore raw
In reply to Irui Wang

Hi,

Le mercredi 20 mars 2024 à 14:13 +0800, Irui Wang a écrit :

Quoted 13 lines

Handle invalid decoder vsi in vpu_dec_init to ensure the decoder vsi is valid for future use.

---
 .../media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c    | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c +0 -0
index 82e57ae983d5..17770993fe5a 100644

drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c int vpu_dec_init(struct vdec_vpu_inst *vpu) · line 239

Quoted 9 lines
drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c +6 -0
@@ -231,6 +231,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;
+	}
+

Make sense, though on the cosmetic side, were is the err value from if the vsi pointer is NULL ?

Nicolas

Quoted 3 lines
drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c +0 -0
 	mtk_vdec_debug(vpu->ctx, "- ret=%d", err);
 	return err;
 }
#4 lore raw

Dear Nicolas,

Thanks for your reviewing.

Quoted 22 lines · Nicolas Dufresne

Hi,

Quoted 19 lines · Irui Wang

Handle invalid decoder vsi in vpu_dec_init to ensure the decoder vsi is
valid for future use.

---
 .../media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c    | 6
++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c index 82e57ae983d5..17770993fe5a 100644

drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c +0 -0
@@ -231,6 +231,12 @@ int vpu_dec_init(struct vdec_vpu_inst *vpu)
 	mtk_vdec_debug(vpu->ctx, "vdec_inst=%p", vpu);
 
Quoted 12 lines

drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c int vpu_dec_init(struct vdec_vpu_inst *vpu) · line 239

Quoted 8 lines
drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c +6 -0
 	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;
+	}
+

Make sense, though on the cosmetic side, were is the err value from if the vsi
pointer is NULL ?

Do you mean the returned 'err'?, it's the status value returned by 'send message'. Even if the 'vsi' is NULL, the returned status value 'err' may still be 'NO_ERROR', there is no direct relationship between them.

If I misunderstood your question, please correct me. Thank you very much.

Quoted 8 lines

Nicolas

Quoted 3 lines
drivers/media/platform/mediatek/vcodec/decoder/vdec_vpu_if.c +0 -0
 	mtk_vdec_debug(vpu->ctx, "- ret=%d", err);
 	return err;

}