video: fixed video coverity error [1/1]
authorPengcheng Chen <pengcheng.chen@amlogic.com>
Wed, 13 Nov 2019 07:20:56 +0000 (15:20 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Mon, 9 Dec 2019 12:10:59 +0000 (05:10 -0700)
PD#SWPL-16572

Problem:
fixed video coverity error

Solution:
fixed video coverity error

Verify:
coverity check

Change-Id: I6c1d865b72148d9f4083300826ef023579cbdb11
Signed-off-by: Pengcheng Chen <pengcheng.chen@amlogic.com>
(cherry picked from commit 8babbb3dbdaf0f75d23b0fce031329c32d00920a)

drivers/amlogic/media/video_processor/video_dev/amlvideo.c
drivers/amlogic/media/video_processor/videosync/videosync.c
drivers/amlogic/media/video_sink/video.c
drivers/amlogic/media/video_sink/vpp.c

index bc424e7ee36ac6fe6d69cf045261c93c350ddf87..7fa1c2f427a66bcbd8e34eb6ca892d7f1755a97e 100644 (file)
@@ -322,15 +322,12 @@ static int vidioc_g_parm(struct file *file, void *priv,
                                struct v4l2_streamparm *parms)
 {
        struct vivi_dev *dev = video_drvdata(file);
-       struct v4l2_amlogic_parm *ap
-               = (struct v4l2_amlogic_parm *)&parms->parm.capture;
 
        if (parms->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
                return -EINVAL;
 
-       memset(ap, 0, sizeof(struct v4l2_amlogic_parm));
-       *ap = dev->am_parm;
-
+       memcpy(parms->parm.raw_data, (u8 *)&dev->am_parm,
+              sizeof(struct v4l2_amlogic_parm));
        return 0;
 }
 
@@ -675,7 +672,6 @@ static int amlvideo_open(struct file *file)
 {
        struct vivi_dev *dev = video_drvdata(file);
        struct vivi_fh *fh = NULL;
-       int retval = 0;
        struct videobuf_res_privdata *res = NULL;
        char *bstart = NULL;
        unsigned int bsize = 0;
@@ -691,6 +687,7 @@ static int amlvideo_open(struct file *file)
        }
        res = kzalloc(sizeof(*res), GFP_KERNEL);
        if ((res == NULL) || (dev->res != NULL)) {
+               kfree(res);
                dev->users--;
                mutex_unlock(&dev->mutex);
                return -ENOMEM;
@@ -700,7 +697,7 @@ static int amlvideo_open(struct file *file)
                        kfree(res);
                        dev->users--;
                        mutex_unlock(&dev->mutex);
-                       retval = -ENOMEM;
+                       return -ENOMEM;
                }
        }
        mutex_unlock(&dev->mutex);
@@ -962,8 +959,9 @@ static int __init amlvideo_create_instance(int inst)
 
 rel_vdev: video_device_release(vfd);
 unreg_dev: v4l2_device_unregister(&dev->v4l2_dev);
-free_dev: kfree(dev);
+free_dev:
        dev->res = NULL;
+       kfree(dev);
        return ret;
 }
 
index 0bd41d8faa895b4d40fd2ff041b2ce6344e54a80..40d0a2170c8da9f9d15a869d0660dd8fc71294a5 100644 (file)
@@ -916,10 +916,11 @@ static long videosync_ioctl(struct file *file,
                        if (dev_id < VIDEOSYNC_S_COUNT)
                                dev_s = &vp_dev->video_prov[dev_id];
 
-                       if (dev_s != NULL && dev_s->mapped)
+                       if (dev_s && dev_s->mapped) {
                                dev_s->show_first_frame_nosync = info[1];
-                       pr_info("show_first_frame_nosync =%d\n",
-                               dev_s->show_first_frame_nosync);
+                               pr_info("show_first_frame_nosync =%d\n",
+                                       dev_s->show_first_frame_nosync);
+                       }
                }
        }
        break;
@@ -985,7 +986,7 @@ static inline bool omx_vpts_expire(struct vframe_s *cur_vf,
                               int toggled_cnt)
 
 {
-       u32 pts = next_vf->pts;
+       u32 pts;
 #ifdef VIDEO_PTS_CHASE
        u32 vid_pts, scr_pts;
 #endif
@@ -996,6 +997,11 @@ static inline bool omx_vpts_expire(struct vframe_s *cur_vf,
        /*u32 dur_pts = 0;*/
        bool expired;
 
+       if (!next_vf)
+               return false;
+
+       pts = next_vf->pts;
+
        if (dev_s->freerun_mode == FREERUN_NODUR)
                return true;
 
@@ -1091,7 +1097,7 @@ static inline bool omx_vpts_expire(struct vframe_s *cur_vf,
                 systime,
                 vsync_pts_inc);
 
-       if (expired && next_vf && next_vf->next_vf_pts_valid &&
+       if (expired && next_vf->next_vf_pts_valid &&
            pts_enforce_pulldown &&
            next_vf->next_vf_pts &&
            (toggled_cnt > 0) &&
@@ -1100,7 +1106,7 @@ static inline bool omx_vpts_expire(struct vframe_s *cur_vf,
                expired = false;
                vp_print(dev_s->vf_receiver_name, PRINT_PATTERN,
                         "force expired false\n");
-       } else if (!expired && next_vf && next_vf->next_vf_pts_valid &&
+       } else if (!expired && next_vf->next_vf_pts_valid &&
                pts_enforce_pulldown &&
                next_vf->next_vf_pts &&
                (toggled_cnt == 0) &&
index 205356333b78a9a397c740f8d8a4d81f0c8294b2..be7c5bb27cef85d13a379c5d0dd6c1f5b10a642a 100644 (file)
@@ -3332,7 +3332,8 @@ static s32 primary_render_frame(struct video_layer_s *layer)
 #endif
 #ifdef TV_3D_FUNCTION_OPEN
        /*turn off vertical scaler when 3d display */
-       if ((layer->dispbuf->type & VIDTYPE_MVC) ||
+       if ((layer->dispbuf &&
+            (layer->dispbuf->type & VIDTYPE_MVC)) ||
            last_mode_3d) {
                layer->sc_setting.sc_v_enable = false;
                config_3d_vd2_pps(
@@ -4794,15 +4795,16 @@ SET_FILTER:
                                pr_info("call process_fun\n");
                }
 #endif
-               cur_dispbuf->process_fun(
-                       cur_dispbuf->private_data,
-                       vd_layer[0].start_x_lines |
-                       (cur_frame_par->vscale_skip_count <<
-                       24) | (frame_par_di_set << 16),
-                       vd_layer[0].end_x_lines,
-                       vd_layer[0].start_y_lines,
-                       vd_layer[0].end_y_lines,
-                       cur_dispbuf);
+               if (cur_frame_par)
+                       cur_dispbuf->process_fun(
+                               cur_dispbuf->private_data,
+                               vd_layer[0].start_x_lines |
+                               (cur_frame_par->vscale_skip_count <<
+                               24) | (frame_par_di_set << 16),
+                               vd_layer[0].end_x_lines,
+                               vd_layer[0].start_y_lines,
+                               vd_layer[0].end_y_lines,
+                               cur_dispbuf);
                di_post_process_done = true;
        }
 exit:
@@ -7764,7 +7766,7 @@ static ssize_t hdmin_delay_start_store(struct class *class,
                        struct class_attribute *attr,
                        const char *buf, size_t count)
 {
-       size_t r;
+       int r;
        int value;
 
        r = kstrtoint(buf, 0, &value);
@@ -7786,7 +7788,7 @@ static ssize_t hdmin_delay_duration_store(struct class *class,
                        struct class_attribute *attr,
                        const char *buf, size_t count)
 {
-       size_t r;
+       int r;
        int value;
 
        r = kstrtoint(buf, 0, &value);
@@ -8714,8 +8716,7 @@ static ssize_t hist_test_store(
                                        VI_HIST_V_START_END, 0);
                                        WRITE_VCBUS_REG(
                                        VI_HIST_PIC_SIZE,
-                                       (ginfo->width & 0xfff) |
-                                       (ginfo->field_height << 16));
+                                       1080 | 1920);
                                        WRITE_VCBUS_REG(VI_HIST_CTRL, 0x3801);
                                }
                        }
index 7389cfe4dedcf22c16c65499bccb57ab54d2f2fb..ea3b17322f10decfa4b4a1bb1bd9ebf98aa4f156 100644 (file)
@@ -862,7 +862,7 @@ static int vpp_set_filters_internal(
        struct vppfilter_mode_s *filter = &next_frame_par->vpp_filter;
        u32 wide_mode;
        s32 height_shift = 0;
-       u32 height_after_ratio;
+       u32 height_after_ratio = 0;
        u32 aspect_factor;
        s32 ini_vphase;
        u32 w_in = width_in;
@@ -1009,7 +1009,7 @@ RESTART:
                sar_height = 1;
        }
 
-       if (ext_sar && sar_width && sar_height) {
+       if (ext_sar && sar_width && sar_height && width_in) {
                aspect_factor =
                        div_u64((u64)256ULL *
                        (u64)sar_height *
@@ -1085,13 +1085,14 @@ RESTART:
                u64 tmp = (u64)((u64)(width_out * width_in) * aspect_ratio_out);
 
                tmp = tmp >> 2;
-               height_after_ratio =
-                       div_u64((u64)256ULL *
-                               (u64)w_in *
-                               (u64)height_out *
-                               (u64)sar_height *
-                               (u64)height_in,
-                               (u32)tmp);
+               if (tmp != 0)
+                       height_after_ratio =
+                               div_u64((u64)256ULL *
+                                       (u64)w_in *
+                                       (u64)height_out *
+                                       (u64)sar_height *
+                                       (u64)height_in,
+                                       (u32)tmp);
                height_after_ratio /= sar_width;
                aspect_factor = (height_after_ratio << 8) / h_in;
                if (super_debug)
@@ -1104,10 +1105,11 @@ RESTART:
                u64 tmp = (u64)((u64)(width_out * h_in) * aspect_ratio_out);
 
                tmp = tmp >> 2;
-               aspect_factor =
-                       div_u64((unsigned long long)w_in * height_out *
-                               (aspect_factor << 8),
-                               (u32)tmp);
+               if (tmp != 0)
+                       aspect_factor =
+                               div_u64((unsigned long long)w_in * height_out *
+                                       (aspect_factor << 8),
+                                       (u32)tmp);
                height_after_ratio = (h_in * aspect_factor) >> 8;
        }