summaryrefslogtreecommitdiff
path: root/drivers/media
diff options
context:
space:
mode:
authorSrikanth Uyyala <suyyala@codeaurora.org>2018-07-24 14:27:38 +0530
committerSrikanth Uyyala <suyyala@codeaurora.org>2018-07-30 14:19:22 +0530
commit21564edd0d3a3b66faac0ca384f2d5f75586f8d5 (patch)
tree490b24e1cc742a187389f899d56b84404f3e0110 /drivers/media
parent595eeed39838e4f975fc1329e500694d8e4b83ea (diff)
mm-camera2:isp2: Add NULL check for stream_info pointer
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>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/msm_isp47.c4
-rw-r--r--drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.c53
2 files changed, 56 insertions, 1 deletions
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp47.c b/drivers/media/platform/msm/camera_v2/isp/msm_isp47.c
index 0a969cc897b0..1f7dec8daaee 100644
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp47.c
+++ b/drivers/media/platform/msm/camera_v2/isp/msm_isp47.c
@@ -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;
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.c b/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.c
index c69bdbf191c6..661850d6d7c6 100644
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.c
+++ b/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.c
@@ -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,