OSDN Git Service

mm-camera2:isp2: Add NULL check for stream_info pointer
authorSrikanth Uyyala <suyyala@codeaurora.org>
Tue, 24 Jul 2018 08:57:38 +0000 (14:27 +0530)
committerSrikanth Uyyala <suyyala@codeaurora.org>
Mon, 30 Jul 2018 08:49:22 +0000 (14:19 +0530)
The function msm_isp_get_stream_common_data could return a NULL,
add check to avoid NULL pointer dereference.

Change-Id: I157a74189b581d8ba90ef31f71c3be9b8369a764
Signed-off-by: Srikanth Uyyala <suyyala@codeaurora.org>
drivers/media/platform/msm/camera_v2/isp/msm_isp47.c
drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.c

index 0a969cc..1f7dec8 100644 (file)
@@ -1904,6 +1904,10 @@ void msm_vfe47_cfg_axi_ub_equal_default(
 
                        stream_info = msm_isp_get_stream_common_data(vfe_dev,
                                        HANDLE_TO_IDX(axi_data->free_wm[i]));
+                       if (!stream_info) {
+                               pr_err("%s: stream_info is NULL!", __func__);
+                               return;
+                       }
                        vfe_idx = msm_isp_get_vfe_idx_for_stream(vfe_dev,
                                                        stream_info);
                        for (plane = 0; plane < stream_info->num_planes;
index c69bdbf..661850d 100644 (file)
@@ -2830,6 +2830,10 @@ static int msm_isp_axi_update_cgc_override(struct vfe_device *vfe_dev_ioctl,
                }
                stream_info = msm_isp_get_stream_common_data(vfe_dev_ioctl,
                        HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i]));
+               if (!stream_info) {
+                       pr_err("%s: stream_info is NULL", __func__);
+                       return -EINVAL;
+               }
                for (j = 0; j < stream_info->num_planes; j++) {
                        for (k = 0; k < stream_info->num_isp; k++) {
                                vfe_dev = stream_info->vfe_dev[k];
@@ -3289,7 +3293,10 @@ static int msm_isp_stop_axi_stream(struct vfe_device *vfe_dev_ioctl,
                        continue;
                stream_info = msm_isp_get_stream_common_data(vfe_dev_ioctl,
                        HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i]));
-
+               if (!stream_info) {
+                       pr_err("%s: stream_info is NULL", __func__);
+                       return -EINVAL;
+               }
                spin_lock_irqsave(&stream_info->lock, flags);
                rc = __msm_isp_check_stream_state(stream_info, 0);
                spin_unlock_irqrestore(&stream_info->lock, flags);
@@ -3326,6 +3333,10 @@ int msm_isp_cfg_axi_stream(struct vfe_device *vfe_dev, void *arg)
                        return -EINVAL;
                stream_info = msm_isp_get_stream_common_data(vfe_dev,
                        HANDLE_TO_IDX(stream_cfg_cmd->stream_handle[i]));
+               if (!stream_info) {
+                       pr_err("%s: stream_info is NULL", __func__);
+                       return -EINVAL;
+               }
                vfe_idx = msm_isp_get_vfe_idx_for_stream_user(vfe_dev,
                                                                stream_info);
                if (vfe_idx == -ENOTTY || stream_info->stream_handle[vfe_idx] !=
@@ -3845,6 +3856,11 @@ int msm_isp_update_axi_stream(struct vfe_device *vfe_dev, void *arg)
                }
                stream_info = msm_isp_get_stream_common_data(vfe_dev,
                        HANDLE_TO_IDX(update_info->stream_handle));
+               if (!stream_info) {
+                       pr_err("%s:%d: stream_info is null",
+                               __func__, __LINE__);
+                       return -EINVAL;
+               }
                if (SRC_TO_INTF(stream_info->stream_src) >= VFE_SRC_MAX)
                        continue;
                if (stream_info->state != ACTIVE &&
@@ -3885,6 +3901,11 @@ int msm_isp_update_axi_stream(struct vfe_device *vfe_dev, void *arg)
                                &update_cmd->update_info[i];
                        stream_info = msm_isp_get_stream_common_data(vfe_dev,
                                HANDLE_TO_IDX(update_info->stream_handle));
+                       if (!stream_info) {
+                               pr_err("%s:%d: stream_info is null",
+                                       __func__, __LINE__);
+                               return -EINVAL;
+                       }
                        stream_info->buf_divert = 0;
                        msm_isp_get_timestamp(&timestamp, vfe_dev);
                        frame_id = vfe_dev->axi_data.src_info[
@@ -3919,6 +3940,11 @@ int msm_isp_update_axi_stream(struct vfe_device *vfe_dev, void *arg)
                                &update_cmd->update_info[i];
                        stream_info = msm_isp_get_stream_common_data(vfe_dev,
                                HANDLE_TO_IDX(update_info->stream_handle));
+                       if (!stream_info) {
+                               pr_err("%s:%d: stream_info is null",
+                                       __func__, __LINE__);
+                               return -EINVAL;
+                       }
                        spin_lock_irqsave(&stream_info->lock, flags);
                        /* no change then break early */
                        if (stream_info->current_framedrop_period ==
@@ -3952,6 +3978,11 @@ int msm_isp_update_axi_stream(struct vfe_device *vfe_dev, void *arg)
                                &update_cmd->update_info[i];
                        stream_info = msm_isp_get_stream_common_data(vfe_dev,
                                HANDLE_TO_IDX(update_info->stream_handle));
+                       if (!stream_info) {
+                               pr_err("%s:%d: stream_info is null",
+                                       __func__, __LINE__);
+                               return -EINVAL;
+                       }
                        sw_skip_info = &update_info->sw_skip_info;
                        if (sw_skip_info->stream_src_mask != 0) {
                                /* SW image buffer drop */
@@ -3976,6 +4007,11 @@ int msm_isp_update_axi_stream(struct vfe_device *vfe_dev, void *arg)
                                &update_cmd->update_info[i];
                        stream_info = msm_isp_get_stream_common_data(vfe_dev,
                                HANDLE_TO_IDX(update_info->stream_handle));
+                       if (!stream_info) {
+                               pr_err("%s:%d: stream_info is null",
+                                       __func__, __LINE__);
+                               return -EINVAL;
+                       }
                        rc = msm_isp_stream_axi_cfg_update(vfe_dev, stream_info,
                                                update_info);
                        if (rc)
@@ -4009,6 +4045,11 @@ int msm_isp_update_axi_stream(struct vfe_device *vfe_dev, void *arg)
                                &update_cmd->update_info[i];
                        stream_info = msm_isp_get_stream_common_data(vfe_dev,
                                HANDLE_TO_IDX(update_info->stream_handle));
+                       if (!stream_info) {
+                               pr_err("%s:%d: stream_info is null",
+                                       __func__, __LINE__);
+                               return -EINVAL;
+                       }
                        rc = msm_isp_add_buf_queue(vfe_dev, stream_info,
                                update_info->user_stream_id);
                        if (rc)
@@ -4023,6 +4064,11 @@ int msm_isp_update_axi_stream(struct vfe_device *vfe_dev, void *arg)
                                &update_cmd->update_info[i];
                        stream_info = msm_isp_get_stream_common_data(vfe_dev,
                                HANDLE_TO_IDX(update_info->stream_handle));
+                       if (!stream_info) {
+                               pr_err("%s:%d: stream_info is null",
+                                       __func__, __LINE__);
+                               return -EINVAL;
+                       }
                        msm_isp_remove_buf_queue(vfe_dev, stream_info,
                                update_info->user_stream_id);
                        pr_debug("%s, Remove bufq for Stream 0x%x\n",
@@ -4059,6 +4105,11 @@ int msm_isp_update_axi_stream(struct vfe_device *vfe_dev, void *arg)
                                &update_cmd->update_info[i];
                        stream_info = msm_isp_get_stream_common_data(vfe_dev,
                                HANDLE_TO_IDX(update_info->stream_handle));
+                       if (!stream_info) {
+                               pr_err("%s:%d: stream_info is null",
+                                       __func__, __LINE__);
+                               return -EINVAL;
+                       }
                        vfe_idx = msm_isp_get_vfe_idx_for_stream(
                                vfe_dev, stream_info);
                        msm_isp_stream_axi_cfg_update(vfe_dev, stream_info,