diff mbox series

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

Message ID 4a357fbe-4f9d-37d1-0be1-93ca754698e9@web.de (mailing list archive)
State New, archived
Headers show
Series [1/2] media: mediatek: vcodec: Delete null pointer checks in vdec_vp9_slice_single_decode() | expand

Commit Message

Markus Elfring April 17, 2023, 12:44 p.m. UTC
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@users.sourceforge.net>
---
 .../platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c  | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

--
2.40.0
diff mbox series

Patch

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);