decoder: fix a kernel panic [1/1]
authorgan.zhang <gan.zhang@amlogic.com>
Tue, 8 Dec 2020 12:11:03 +0000 (20:11 +0800)
committergan.zhang <gan.zhang@amlogic.com>
Wed, 13 Jan 2021 06:45:14 +0000 (14:45 +0800)
PD#SWPL-38642

Problem:
Cause crash when vf in null

Solution:
Check for null pointer.

Verify:
AH212

Change-Id: I41583004e735c40c71e50de6818e6f097a68a6a0
Signed-off-by: gan.zhang <gan.zhang@amlogic.com>
drivers/frame_provider/decoder/avs2/vavs2.c
drivers/frame_provider/decoder/h264_multi/vmh264.c
drivers/frame_provider/decoder/mjpeg/vmjpeg_multi.c
drivers/frame_provider/decoder/mpeg4/vmpeg4_multi.c
drivers/frame_provider/decoder/vp9/vvp9.c

index 688f3f7c29bec5925e1bcb8daf1184eef3e2dc43..de726644d1f36924014dbc2127468ffa8e296594 100644 (file)
@@ -4184,11 +4184,16 @@ static struct vframe_s *vavs2_vf_get(void *op_arg)
 static void vavs2_vf_put(struct vframe_s *vf, void *op_arg)
 {
        struct AVS2Decoder_s *dec = (struct AVS2Decoder_s *)op_arg;
-       uint8_t index = vf->index & 0xff;
+       uint8_t index;
 
        if (vf == (&dec->vframe_dummy))
                return;
 
+       if (!vf)
+               return;
+
+       index = vf->index & 0xff;
+
        kfifo_put(&dec->newframe_q, (const struct vframe_s *)vf);
        dec->vf_put_count++;
        avs2_print(dec, AVS2_DBG_BUFMGR,
index 8366c053467bf4d4a748bacb56a191b33ba1a4f0..53894057a263c4651ec920275e729439fbbfce7d 100644 (file)
@@ -4309,6 +4309,10 @@ static void vh264_vf_put(struct vframe_s *vf, void *op_arg)
 
        if (vf == (&hw->vframe_dummy))
                return;
+
+       if (!vf)
+               return;
+
        if (vf->index == -1) {
                dpb_print(DECODE_ID(hw), 0,
                        "Warning: %s vf %p invalid index\r\n",
index 947a8b5deec07caaa2346f8890b5aad4be8ccbd6..df3991cef0ab3f29d86ae26392fea235c6e30f3e 100644 (file)
@@ -495,6 +495,10 @@ static void vmjpeg_vf_put(struct vframe_s *vf, void *op_arg)
 {
        struct vdec_s *vdec = op_arg;
        struct vdec_mjpeg_hw_s *hw = (struct vdec_mjpeg_hw_s *)vdec->private;
+
+       if (!vf)
+               return;
+
        mmjpeg_debug_print(DECODE_ID(hw), PRINT_FRAME_NUM,
                "%s:put_num:%d\n", __func__, hw->put_num);
        hw->vfbuf_use[vf->index]--;
index 65111c2ad6e8e7761e3b5cf56673f5229c435e3d..acca6bc9dfa82877f5f06c2d556328a3d57348ca 100644 (file)
@@ -1646,6 +1646,9 @@ static void vmpeg_vf_put(struct vframe_s *vf, void *op_arg)
        struct vdec_s *vdec = op_arg;
        struct vdec_mpeg4_hw_s *hw = (struct vdec_mpeg4_hw_s *)vdec->private;
 
+       if (!vf)
+               return;
+
        hw->vfbuf_use[vf->index]--;
        hw->put_num++;
        mmpeg4_debug_print(DECODE_ID(hw), PRINT_FRAME_NUM,
index 876dc8bd5bab8f255f59cbc692c33af70d4b2698..d9a64c2d837c257aab0d49d91f6577a176d591f4 100644 (file)
@@ -6992,11 +6992,16 @@ static struct vframe_s *vvp9_vf_get(void *op_arg)
 static void vvp9_vf_put(struct vframe_s *vf, void *op_arg)
 {
        struct VP9Decoder_s *pbi = (struct VP9Decoder_s *)op_arg;
-       uint8_t index = vf->index & 0xff;
+       uint8_t index;
 
        if (vf == (&pbi->vframe_dummy))
                return;
 
+       if (!vf)
+               return;
+
+       index = vf->index & 0xff;
+
        if (pbi->enable_fence && vf->fence) {
                vdec_fence_put(vf->fence);
                vf->fence = NULL;