Browse Source

msm: camera: reqmgr: Assign proper init value to min delay

The apply_data can be accessed by DELAY_MAX if min delay
is initial value, it will cause out of array bound issue.
This change assign DELAY_2 to the min delay, DELAY_2 is a
value array index to apply_data.

CRs-Fixed: 3244492
Change-Id: I16e73e562488058cea68c76c1aaa9dcfeb0c2d9a
Signed-off-by: Depeng Shao <[email protected]>
Depeng Shao 3 years ago
parent
commit
1067cc03bd
1 changed files with 10 additions and 4 deletions
  1. 10 4
      drivers/cam_req_mgr/cam_req_mgr_core.c

+ 10 - 4
drivers/cam_req_mgr/cam_req_mgr_core.c

@@ -39,7 +39,7 @@ void cam_req_mgr_core_link_reset(struct cam_req_mgr_core_link *link)
 	link->link_hdl = 0;
 	link->link_hdl = 0;
 	link->num_devs = 0;
 	link->num_devs = 0;
 	link->max_delay = CAM_PIPELINE_DELAY_0;
 	link->max_delay = CAM_PIPELINE_DELAY_0;
-	link->min_delay = CAM_PIPELINE_DELAY_MAX;
+	link->min_delay = CAM_PIPELINE_DELAY_2;
 	link->workq = NULL;
 	link->workq = NULL;
 	link->pd_mask = 0;
 	link->pd_mask = 0;
 	link->l_dev = NULL;
 	link->l_dev = NULL;
@@ -447,6 +447,12 @@ static int __cam_req_mgr_notify_error_on_link(
 		return -EINVAL;
 		return -EINVAL;
 	}
 	}
 
 
+	if (link->min_delay >= CAM_PIPELINE_DELAY_MAX) {
+		CAM_ERR(CAM_CRM, "min pd : %d is more than expected",
+			link->min_delay);
+		return -EINVAL;
+	}
+
 	/* Notify all devices in the link about the error */
 	/* Notify all devices in the link about the error */
 	__cam_req_mgr_send_evt(link->req.apply_data[link->min_delay].req_id,
 	__cam_req_mgr_send_evt(link->req.apply_data[link->min_delay].req_id,
 		CAM_REQ_MGR_LINK_EVT_STALLED, CRM_KMD_ERR_FATAL, link);
 		CAM_REQ_MGR_LINK_EVT_STALLED, CRM_KMD_ERR_FATAL, link);
@@ -2517,7 +2523,7 @@ static void __cam_req_mgr_destroy_link_info(struct cam_req_mgr_core_link *link)
 	link->pd_mask = 0;
 	link->pd_mask = 0;
 	link->num_devs = 0;
 	link->num_devs = 0;
 	link->max_delay = CAM_PIPELINE_DELAY_0;
 	link->max_delay = CAM_PIPELINE_DELAY_0;
-	link->min_delay = CAM_PIPELINE_DELAY_MAX;
+	link->min_delay = CAM_PIPELINE_DELAY_2;
 }
 }
 
 
 /**
 /**
@@ -2566,8 +2572,8 @@ static struct cam_req_mgr_core_link *__cam_req_mgr_reserve_link(
 
 
 	mutex_lock(&link->lock);
 	mutex_lock(&link->lock);
 	link->num_devs = 0;
 	link->num_devs = 0;
-	link->max_delay = 0;
-	link->min_delay = CAM_PIPELINE_DELAY_MAX;
+	link->max_delay = CAM_PIPELINE_DELAY_0;
+	link->min_delay = CAM_PIPELINE_DELAY_2;
 	memset(in_q->slot, 0,
 	memset(in_q->slot, 0,
 		sizeof(struct cam_req_mgr_slot) * MAX_REQ_SLOTS);
 		sizeof(struct cam_req_mgr_slot) * MAX_REQ_SLOTS);
 	link->req.in_q = in_q;
 	link->req.in_q = in_q;