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

Commit 77d6979e authored by Jigarkumar Zala's avatar Jigarkumar Zala Committed by Gerrit - the friendly Code Review server
Browse files

msm: camera: Change the mutex lock acquire in flush



mutex lock is getting acquire without null check. This change
fixes the issue by moving the mutex acquire lock after getting
valid pointer.

Change-Id: Id6656dc92685183d5b11085f0888bb8fc29dc713
Signed-off-by: default avatarJigarkumar Zala <jzala@codeaurora.org>
parent ee02364c
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -901,21 +901,19 @@ int32_t cam_actuator_flush_request(struct cam_req_mgr_flush_request *flush_req)
	if (!flush_req)
		return -EINVAL;

	mutex_lock(&(a_ctrl->actuator_mutex));
	a_ctrl = (struct cam_actuator_ctrl_t *)
		cam_get_device_priv(flush_req->dev_hdl);
	if (!a_ctrl) {
		CAM_ERR(CAM_ACTUATOR, "Device data is NULL");
		rc = -EINVAL;
		goto end;
		return -EINVAL;
	}

	if (a_ctrl->i2c_data.per_frame == NULL) {
		CAM_ERR(CAM_ACTUATOR, "i2c frame data is NULL");
		rc = -EINVAL;
		goto end;
		return -EINVAL;
	}

	mutex_lock(&(a_ctrl->actuator_mutex));
	if (flush_req->type == CAM_REQ_MGR_FLUSH_TYPE_ALL) {
		a_ctrl->last_flush_req = flush_req->req_id;
		CAM_DBG(CAM_ACTUATOR, "last reqest to flush is %lld",
@@ -949,7 +947,6 @@ int32_t cam_actuator_flush_request(struct cam_req_mgr_flush_request *flush_req)
		CAM_DBG(CAM_ACTUATOR,
			"Flush request id:%lld not found in the pending list",
			flush_req->req_id);
end:
	mutex_unlock(&(a_ctrl->actuator_mutex));
	return rc;
}
+2 −3
Original line number Diff line number Diff line
@@ -387,14 +387,13 @@ int cam_flash_flush_request(struct cam_req_mgr_flush_request *flush)
	int rc = 0;
	struct cam_flash_ctrl *fctrl = NULL;

	mutex_lock(&fctrl->flash_mutex);
	fctrl = (struct cam_flash_ctrl *) cam_get_device_priv(flush->dev_hdl);
	if (!fctrl) {
		CAM_ERR(CAM_FLASH, "Device data is NULL");
		rc = -EINVAL;
		goto end;
		return -EINVAL;
	}

	mutex_lock(&fctrl->flash_mutex);
	if (flush->type == CAM_REQ_MGR_FLUSH_TYPE_ALL) {
		fctrl->last_flush_req = flush->req_id;
		CAM_DBG(CAM_FLASH, "last reqest to flush is %lld",
+3 −6
Original line number Diff line number Diff line
@@ -1197,21 +1197,19 @@ int32_t cam_sensor_flush_request(struct cam_req_mgr_flush_request *flush_req)
	if (!flush_req)
		return -EINVAL;

	mutex_lock(&(s_ctrl->cam_sensor_mutex));
	s_ctrl = (struct cam_sensor_ctrl_t *)
		cam_get_device_priv(flush_req->dev_hdl);
	if (!s_ctrl) {
		CAM_ERR(CAM_SENSOR, "Device data is NULL");
		rc = -EINVAL;
		goto end;
		return -EINVAL;
	}

	if (s_ctrl->i2c_data.per_frame == NULL) {
		CAM_ERR(CAM_SENSOR, "i2c frame data is NULL");
		rc = -EINVAL;
		goto end;
		return -EINVAL;
	}

	mutex_lock(&(s_ctrl->cam_sensor_mutex));
	if (flush_req->type == CAM_REQ_MGR_FLUSH_TYPE_ALL) {
		s_ctrl->last_flush_req = flush_req->req_id;
		CAM_DBG(CAM_SENSOR, "last reqest to flush is %lld",
@@ -1245,7 +1243,6 @@ int32_t cam_sensor_flush_request(struct cam_req_mgr_flush_request *flush_req)
		CAM_DBG(CAM_SENSOR,
			"Flush request id:%lld not found in the pending list",
			flush_req->req_id);
end:
	mutex_unlock(&(s_ctrl->cam_sensor_mutex));
	return rc;
}