[PATCH 2/2] media: mediatek: vcodec: Move variable assignments behind null pointer checks in vdec_vp9_slice_single_decode()

Markus Elfring Markus.Elfring at web.de
Mon Apr 17 05:44:14 PDT 2023


Date: Mon, 17 Apr 2023 14:19:13 +0200

The addresses which were assigned to the variables “instance”,
“pfc” and “ctx” would not be used if a null pointer was passed by
the input parameter “bs”.
Thus move these assignments behind corresponding pointer checks.

Signed-off-by: Markus Elfring <elfring at users.sourceforge.net>
---
 .../platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c  | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c
index 8430098ed0b1..562fe07d3731 100644
--- a/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c
+++ b/drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c
@@ -1989,22 +1989,23 @@ static int vdec_vp9_slice_get_param(void *h_vdec, enum vdec_get_param_type type,
 static int vdec_vp9_slice_single_decode(void *h_vdec, struct mtk_vcodec_mem *bs,
 					struct vdec_fb *fb, bool *res_chg)
 {
-	struct vdec_vp9_slice_instance *instance = h_vdec;
-	struct vdec_vp9_slice_pfc *pfc = &instance->sc_pfc;
+	struct vdec_vp9_slice_instance *instance;
+	struct vdec_vp9_slice_pfc *pfc;
 	struct vdec_vp9_slice_vsi *vsi;
 	struct mtk_vcodec_ctx *ctx;
 	int ret;

-	ctx = instance->ctx;
-
 	/* bs NULL means flush decoder */
 	if (!bs)
 		return vdec_vp9_slice_flush(h_vdec, bs, fb, res_chg);

+	instance = h_vdec;
+	ctx = instance->ctx;
 	fb = ctx->dev->vdec_pdata->get_cap_buffer(ctx);
 	if (!fb)
 		return -EBUSY;

+	pfc = &instance->sc_pfc;
 	vsi = &pfc->vsi;

 	ret = vdec_vp9_slice_setup_single(instance, bs, fb, pfc);
--
2.40.0




More information about the Linux-mediatek mailing list