Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a7502f4f authored by Xu Han's avatar Xu Han
Browse files

msm: camera: Checking an enum value greater than zero



An enum value cci_i2c_master is not checked to be greater than 0.
Add the check.

Change-Id: Ibe75ab7155def45d81b8127c5eda3fa2ed570bce
Signed-off-by: default avatarXu Han <hanxu@codeaurora.org>
parent 9181b869
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -479,7 +479,8 @@ static int32_t msm_cci_i2c_read_bytes(struct v4l2_subdev *sd,
		return -EINVAL;
	}

	if (c_ctrl->cci_info->cci_i2c_master > MASTER_MAX) {
	if (c_ctrl->cci_info->cci_i2c_master > MASTER_MAX
			|| c_ctrl->cci_info->cci_i2c_master < 0) {
		pr_err("%s:%d Invalid I2C master addr\n", __func__, __LINE__);
		return -EINVAL;
	}
@@ -524,7 +525,8 @@ static int32_t msm_cci_i2c_write(struct v4l2_subdev *sd,
	enum cci_i2c_master_t master;
	enum cci_i2c_queue_t queue = QUEUE_0;
	cci_dev = v4l2_get_subdevdata(sd);
	if (c_ctrl->cci_info->cci_i2c_master > MASTER_MAX) {
	if (c_ctrl->cci_info->cci_i2c_master > MASTER_MAX
			|| c_ctrl->cci_info->cci_i2c_master < 0) {
		pr_err("%s:%d Invalid I2C master addr\n", __func__, __LINE__);
		return -EINVAL;
	}
@@ -661,7 +663,7 @@ static int32_t msm_cci_init(struct v4l2_subdev *sd,
		CDBG("%s ref_count %d\n", __func__, cci_dev->ref_count);
		master = c_ctrl->cci_info->cci_i2c_master;
		CDBG("%s:%d master %d\n", __func__, __LINE__, master);
		if (master < MASTER_MAX) {
		if (master < MASTER_MAX && master >= 0) {
			mutex_lock(&cci_dev->cci_master_info[master].mutex);
			/* Set reset pending flag to TRUE */
			cci_dev->cci_master_info[master].reset_pending = TRUE;