msm: camera: Add some minor code fixes.

Add couple of valid ptr checks and zero out
variables after allocation.

Change-Id: Ib0e80eab9ac41cec192d1c4a04f8aeafd77729a3
Signed-off-by: Kiran Kumar H N <hurlisal@codeaurora.org>
This commit is contained in:
Kiran Kumar H N 2012-07-12 13:51:17 -07:00 committed by Stephen Boyd
parent e5f67cc2bd
commit 1f46befd73
6 changed files with 21 additions and 5 deletions

View file

@ -218,6 +218,7 @@ int msm_gemini_evt_get(struct msm_gemini_device *pgmn_dev,
return -EAGAIN;
}
memset(&ctrl_cmd, 0, sizeof(struct msm_gemini_ctrl_cmd));
ctrl_cmd.type = buf_p->vbuf.type;
kfree(buf_p);

View file

@ -888,7 +888,10 @@ static int msm_open(struct file *f)
goto msm_cam_server_begin_session_failed;
}
pmctl = msm_cam_server_get_mctl(pcam->mctl_handle);
if (!pmctl) {
pr_err("%s mctl ptr is null ", __func__);
goto msm_cam_server_begin_session_failed;
}
#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
pmctl->client = msm_ion_client_create(-1, "camera");
kref_init(&pmctl->refcount);

View file

@ -437,7 +437,7 @@ static int msm_mctl_open(struct msm_cam_media_controller *p_mctl,
/* open sub devices - once only*/
if (!p_mctl->opencnt) {
struct msm_sensor_csi_info csi_info;
uint32_t csid_version;
uint32_t csid_version = 0;
wake_lock(&p_mctl->wake_lock);
csid_core = camdev->csid_core;
@ -1327,6 +1327,10 @@ static int msm_mctl_v4l2_s_fmt_cap(struct file *f, void *pctx,
WARN_ON(pctx != f->private_data);
pmctl = msm_cam_server_get_mctl(pcam->mctl_handle);
if (!pmctl) {
pr_err("%s mctl ptr is null ", __func__);
return -EINVAL;
}
if (!pcam_inst->vbqueue_initialized) {
pmctl->mctl_vbqueue_init(pcam_inst, &pcam_inst->vid_bufq,
V4L2_BUF_TYPE_VIDEO_CAPTURE);
@ -1351,6 +1355,10 @@ static int msm_mctl_v4l2_s_fmt_cap_mplane(struct file *f, void *pctx,
WARN_ON(pctx != f->private_data);
pmctl = msm_cam_server_get_mctl(pcam->mctl_handle);
if (!pmctl) {
pr_err("%s mctl ptr is null ", __func__);
return -EINVAL;
}
if (!pcam_inst->vbqueue_initialized) {
pmctl->mctl_vbqueue_init(pcam_inst, &pcam_inst->vid_bufq,
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);

View file

@ -4754,7 +4754,8 @@ int msm_axi_subdev_init(struct v4l2_subdev *sd)
return rc;
clk_enable_failed:
regulator_disable(axi_ctrl->fs_vfe);
if (axi_ctrl->fs_vfe)
regulator_disable(axi_ctrl->fs_vfe);
fs_failed:
iounmap(axi_ctrl->share_ctrl->vfebase);
axi_ctrl->share_ctrl->vfebase = NULL;
@ -4932,12 +4933,14 @@ static int msm_axi_config(struct v4l2_subdev *sd, void __user *arg)
pr_err("%s: base address unmapped\n", __func__);
return -EFAULT;
}
memset(&cfgcmd, 0, sizeof(struct msm_vfe_cfg_cmd));
if (NULL != arg) {
if (copy_from_user(&cfgcmd, arg, sizeof(cfgcmd))) {
ERR_COPY_FROM_USER();
return -EFAULT;
}
}
memset(&vfecmd, 0, sizeof(struct msm_isp_cmd));
if (NULL != cfgcmd.value) {
if (copy_from_user(&vfecmd,
(void __user *)(cfgcmd.value),

View file

@ -545,7 +545,8 @@ int vpe_enable(uint32_t clk_rate)
return rc;
vpe_clk_failed:
regulator_disable(vpe_ctrl->fs_vpe);
if (vpe_ctrl->fs_vpe)
regulator_disable(vpe_ctrl->fs_vpe);
vpe_fs_failed:
disable_irq(vpe_ctrl->vpeirq->start);
vpe_ctrl->state = VPE_STATE_IDLE;

View file

@ -1783,7 +1783,7 @@ int msm_cam_server_request_irq(void *arg)
* the individual irq lookup table.... */
irq_req->irq_idx =
get_irq_idx_from_camhw_idx(irq_req->cam_hw_idx);
if (irq_req->cam_hw_idx < 0) {
if (irq_req->irq_idx < 0) {
pr_err("%s Invalid hw index %d ", __func__,
irq_req->cam_hw_idx);
return -EINVAL;