wlan: WDI: Check error condition on inserting node

Check error condition on inserting node to wpal list
and handle it properly.

CRs-Fixed: 687963
Change-Id: I05e7e5071203eb9741410382c79895ec2105a263
diff --git a/CORE/WDI/CP/src/wlan_qct_wdi.c b/CORE/WDI/CP/src/wlan_qct_wdi.c
index b204a7e..6d99130 100644
--- a/CORE/WDI/CP/src/wlan_qct_wdi.c
+++ b/CORE/WDI/CP/src/wlan_qct_wdi.c
@@ -22219,7 +22219,16 @@
   /*Send wpt a pointer to the node (this is the 1st element in the event data)*/
   pNode = (wpt_list_node*)pEventDataQueue;
 
-  wpal_list_insert_back(&(pWDICtx->wptPendingQueue), pNode);
+  if (eWLAN_PAL_STATUS_E_FAILURE ==
+            wpal_list_insert_back(&(pWDICtx->wptPendingQueue), pNode))
+  {
+      WPAL_TRACE(eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_ERROR,
+                "pEventDataQueue wpal_list_insert_back failed");
+      WDI_ASSERT(0);
+      wpalMemoryFree(pEventDataQueue);
+      wpalMemoryFree(pEventInfo);
+      return WDI_STATUS_MEM_FAILURE;
+  }
 
   return WDI_STATUS_SUCCESS;
 }/*WDI_QueuePendingReq*/
@@ -22492,7 +22501,17 @@
   /*This association is currently being queued*/
   pSession->bAssocReqQueued = eWLAN_PAL_TRUE;
 
-  wpal_list_insert_back(&(pSession->wptPendingQueue), pNode);
+  if (eWLAN_PAL_STATUS_E_FAILURE ==
+            wpal_list_insert_back(&(pSession->wptPendingQueue), pNode))
+  {
+    WPAL_TRACE(eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_ERROR,
+           "%s: pEventDataQueue wpal_list_insert_back failed", __func__);
+    WDI_ASSERT(0);
+    wpalMemoryFree(pSessionIdElement);
+    wpalMemoryFree(pEventDataQueue);
+    wpalMemoryFree(pEventInfo);
+    return WDI_STATUS_MEM_FAILURE;
+  }
 
   /*We need to maintain a separate list that keeps track of the order in which
   the new assoc requests are being queued such that we can start processing
@@ -22502,7 +22521,17 @@
 
   WPAL_TRACE(eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_INFO,
        "Queueing up new assoc session : %d ", pSessionIdElement->ucIndex);
-  wpal_list_insert_back(&pWDICtx->wptPendingAssocSessionIdQueue, pNode);
+  if (eWLAN_PAL_STATUS_E_FAILURE ==
+         wpal_list_insert_back(&pWDICtx->wptPendingAssocSessionIdQueue, pNode))
+  {
+    WPAL_TRACE(eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_ERROR,
+           "%s: pSessionIdElement wpal_list_insert_back failed", __func__);
+    WDI_ASSERT(0);
+    wpalMemoryFree(pSessionIdElement);
+    wpalMemoryFree(pEventDataQueue);
+    wpalMemoryFree(pEventInfo);
+    return WDI_STATUS_MEM_FAILURE;
+  }
 
   /*Return pending as this is what the status of the request is since it has
     been queued*/
@@ -22585,7 +22614,17 @@
   /*This association is currently being queued*/
   pSession->bAssocReqQueued = eWLAN_PAL_TRUE;
 
-  wpal_list_insert_back(&(pSession->wptPendingQueue), pNode);
+  if (eWLAN_PAL_STATUS_E_FAILURE ==
+          wpal_list_insert_back(&(pSession->wptPendingQueue), pNode))
+  {
+    WPAL_TRACE(eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_ERROR,
+               "%s: Cannot allocate memory for queueing event data info",
+               __func__);
+    WDI_ASSERT(0);
+    wpalMemoryFree(pEventDataQueue);
+    wpalMemoryFree(pEventInfo);
+    return WDI_STATUS_MEM_FAILURE;
+  }
 
   /*The result of this operation is pending because the request has been
     queued and it will be processed at a later moment in time */
diff --git a/CORE/WDI/TRP/CTS/src/wlan_qct_wdi_cts.c b/CORE/WDI/TRP/CTS/src/wlan_qct_wdi_cts.c
index db547af..82ac70e 100644
--- a/CORE/WDI/TRP/CTS/src/wlan_qct_wdi_cts.c
+++ b/CORE/WDI/TRP/CTS/src/wlan_qct_wdi_cts.c
@@ -976,7 +976,18 @@
 
       pBufferQueue->bufferSize = len;
       pBufferQueue->pBuffer = pMsg;
-      wpal_list_insert_back(&pWCTSCb->wctsPendingQueue, &pBufferQueue->node);
+
+      if (eWLAN_PAL_STATUS_E_FAILURE ==
+             wpal_list_insert_back(&pWCTSCb->wctsPendingQueue,
+                 &pBufferQueue->node))
+      {
+         WPAL_TRACE(eWLAN_MODULE_DAL_CTRL, eWLAN_PAL_TRACE_LEVEL_ERROR,
+                    "pBufferQueue wpal_list_insert_back failed");
+         wpalMemoryFree(pMsg);
+         wpalMemoryFree(pBufferQueue);
+         WPAL_ASSERT(0);
+         return eWLAN_PAL_STATUS_E_NOMEM;
+      }
 
       /* if we are not already in the deferred state, then transition
          to that state.  when we do so, we enable the remote read