qcacld-3.0: Avoid sending P2P action frame confirmation twice

qcacld-2.0 to qcacld-3.0 propagation..

P2P action frame confirmation can be called from work queue
wma_mgmt_tx_ack_work_handler as well as from MC thread during
remain on channel completion. So it can lead to race condition
where frame confirmation is called twice and driver tries to free
frame buffer twice.

To detect duplicate use PE global lock in P2P action frame
confirmation.

Change-Id: Id193b5a979fad5effa7c6b00d89452ad876ae00e
CRs-Fixed: 1035077
diff --git a/core/mac/src/pe/lim/lim_p2p.c b/core/mac/src/pe/lim/lim_p2p.c
index cda4b10..9485f12 100644
--- a/core/mac/src/pe/lim/lim_p2p.c
+++ b/core/mac/src/pe/lim/lim_p2p.c
@@ -412,16 +412,31 @@
 
 QDF_STATUS lim_p2p_action_cnf(tpAniSirGlobal pMac, uint32_t txCompleteSuccess)
 {
-	if (pMac->lim.mgmtFrameSessionId != 0xff) {
-		/* The session entry might be invalid(0xff) action confirmation received after
-		 * remain on channel timer expired */
-		if (pMac->p2p_ack_ind_cb)
-			pMac->p2p_ack_ind_cb(pMac->lim.mgmtFrameSessionId,
-							txCompleteSuccess);
+	QDF_STATUS status;
+	uint32_t mgmt_frame_sessionId;
+
+	status = pe_acquire_global_lock(&pMac->lim);
+	if (QDF_IS_STATUS_SUCCESS(status)) {
+		mgmt_frame_sessionId = pMac->lim.mgmtFrameSessionId;
 		pMac->lim.mgmtFrameSessionId = 0xff;
+		pe_release_global_lock(&pMac->lim);
+
+		if (mgmt_frame_sessionId != 0xff) {
+			/*
+			 * The session entry might be invalid(0xff)
+			 * action confirmation received after
+			 * remain on channel timer expired.
+			 */
+			lim_log(pMac, LOG1,
+				FL("mgmt_frame_sessionId %d"),
+					 mgmt_frame_sessionId);
+			if (pMac->p2p_ack_ind_cb)
+				pMac->p2p_ack_ind_cb(mgmt_frame_sessionId,
+							txCompleteSuccess);
+		}
 	}
 
-	return QDF_STATUS_SUCCESS;
+	return status;
 }
 
 /**