Ver código fonte

msm: camera: reqmgr: check link state before taking mutex

In case if the destroy session is processed first it will
as a part of unlink try to drain the work queue. This will
schedule all the enqueued wq. Workqueue when scheduled
try to acquire same mutex destroy session has already acquried
this will lead to dead-lock. To avoid that, check the link
state first if it is in idle state then return from the
workqueue without trying to acquire mutex.

CRs-Fixed: 2976325
Change-Id: I57a53455c69e5f4f38c92413f9d1b7f2d06c9960
Signed-off-by: Tejas Prajapati <[email protected]>
Tejas Prajapati 4 anos atrás
pai
commit
29e76ca7d2
1 arquivos alterados com 13 adições e 0 exclusões
  1. 13 0
      drivers/cam_req_mgr/cam_req_mgr_core.c

+ 13 - 0
drivers/cam_req_mgr/cam_req_mgr_core.c

@@ -1379,6 +1379,19 @@ static int __cam_req_mgr_process_req(struct cam_req_mgr_core_link *link,
 		return -EINVAL;
 	}
 
+	/*
+	 * In case if the wq is scheduled while destroying session
+	 * the session mutex is already taken and will cause a
+	 * dead lock. To avoid further processing check link state
+	 * and exit.
+	 */
+	spin_lock_bh(&link->link_state_spin_lock);
+	if (link->state == CAM_CRM_LINK_STATE_IDLE) {
+		spin_unlock_bh(&link->link_state_spin_lock);
+		return -EPERM;
+	}
+	spin_unlock_bh(&link->link_state_spin_lock);
+
 	mutex_lock(&session->lock);
 	in_q = link->req.in_q;
 	/*