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

Commit 0aba438e authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: camera: Add NULL check in msm_actuator"

parents 5afc9192 e1183e4f
Loading
Loading
Loading
Loading
+35 −4
Original line number Original line Diff line number Diff line
@@ -83,13 +83,23 @@ static int32_t msm_actuator_piezo_set_default_focus(
static void msm_actuator_parse_i2c_params(struct msm_actuator_ctrl_t *a_ctrl,
static void msm_actuator_parse_i2c_params(struct msm_actuator_ctrl_t *a_ctrl,
	int16_t next_lens_position, uint32_t hw_params, uint16_t delay)
	int16_t next_lens_position, uint32_t hw_params, uint16_t delay)
{
{
	struct msm_actuator_reg_params_t *write_arr = a_ctrl->reg_tbl;
	struct msm_actuator_reg_params_t *write_arr = NULL;
	uint32_t hw_dword = hw_params;
	uint32_t hw_dword = hw_params;
	uint16_t i2c_byte1 = 0, i2c_byte2 = 0;
	uint16_t i2c_byte1 = 0, i2c_byte2 = 0;
	uint16_t value = 0;
	uint16_t value = 0;
	uint32_t size = a_ctrl->reg_tbl_size, i = 0;
	uint32_t size = 0, i = 0;
	struct msm_camera_i2c_reg_array *i2c_tbl = a_ctrl->i2c_reg_tbl;
	struct msm_camera_i2c_reg_array *i2c_tbl = NULL;
	CDBG("Enter\n");
	CDBG("Enter\n");

	if (a_ctrl == NULL) {
		pr_err("failed. actuator ctrl is NULL");
		return;
	}

	size = a_ctrl->reg_tbl_size;
	write_arr = a_ctrl->reg_tbl;
	i2c_tbl = a_ctrl->i2c_reg_tbl;

	for (i = 0; i < size; i++) {
	for (i = 0; i < size; i++) {
		/* check that the index into i2c_tbl cannot grow larger that
		/* check that the index into i2c_tbl cannot grow larger that
		the allocated size of i2c_tbl */
		the allocated size of i2c_tbl */
@@ -1082,6 +1092,17 @@ static int32_t msm_actuator_set_position(
		return -EFAULT;
		return -EFAULT;
	}
	}


	if (!a_ctrl || !a_ctrl->func_tbl ||
		!a_ctrl->func_tbl->actuator_parse_i2c_params) {
		pr_err("failed. NULL actuator pointers.");
		return -EFAULT;
	}

	if (a_ctrl->actuator_state != ACT_OPS_ACTIVE) {
		pr_err("failed. Invalid actuator state.");
		return -EFAULT;
	}

	a_ctrl->i2c_tbl_index = 0;
	a_ctrl->i2c_tbl_index = 0;
	for (index = 0; index < set_pos->number_of_steps; index++) {
	for (index = 0; index < set_pos->number_of_steps; index++) {
		next_lens_position = set_pos->pos[index];
		next_lens_position = set_pos->pos[index];
@@ -1124,6 +1145,16 @@ static int32_t msm_actuator_bivcm_set_position(
		return -EFAULT;
		return -EFAULT;
	}
	}


	if (!a_ctrl) {
		pr_err("failed. NULL actuator pointers.");
		return -EFAULT;
	}

	if (a_ctrl->actuator_state != ACT_OPS_ACTIVE) {
		pr_err("failed. Invalid actuator state.");
		return -EFAULT;
	}

	a_ctrl->i2c_tbl_index = 0;
	a_ctrl->i2c_tbl_index = 0;
	hw_params = set_pos->hw_params;
	hw_params = set_pos->hw_params;
	for (index = 0; index < set_pos->number_of_steps; index++) {
	for (index = 0; index < set_pos->number_of_steps; index++) {