Wlan: Replaced mutex_lock_interruptible with mutex_lock

In the current implementation we are using mutex_lock_interruptible
while trying to access the vos packet lists now made the change to make
use of mutex_lock insted of mutex_lock_interruptible so that the task
doesn't get interrupted while trying to modify the list.Also in while
releasing the packet back to free list we were just ignoring whether we
have succesfully acquired the lock or no and we are trying to access the
list which could result in the corruption of the list.so made sure we
access the list after acquiring the lock.

Change-Id: I53de8089e6dc994c13b1836bef6091aa0ef21d49
CR-Fixed: 396460
diff --git a/CORE/VOSS/src/vos_packet.c b/CORE/VOSS/src/vos_packet.c
index cb7b869..211c643 100644
--- a/CORE/VOSS/src/vos_packet.c
+++ b/CORE/VOSS/src/vos_packet.c
@@ -166,7 +166,6 @@
    struct vos_pkt_t *pVosPacket;
    v_BOOL_t didOne = VOS_FALSE;
    vos_pkt_get_packet_callback callback;
-   int rc; 
 
    // if there are no packets in the replenish pool then we can't do anything
    if (likely(0 == gpVosPacketContext->rxReplenishListCount))
@@ -174,22 +173,17 @@
       return;
    }
 
+   // we only replenish if the Rx Raw pool is empty or the Replenish pool
+   // reaches a high water mark
+   mutex_lock(&gpVosPacketContext->mlock);
+
+
    if ((gpVosPacketContext->rxReplenishListCount < VPKT_RX_REPLENISH_THRESHOLD)
        &&
        (!list_empty(&gpVosPacketContext->rxRawFreeList)))
-    {
-      return;
-    }
-
-   // we only replenish if the Rx Raw pool is empty or the Replenish pool
-   // reaches a high water mark
-   rc = mutex_lock_interruptible(&gpVosPacketContext->mlock);
-
-   if (unlikely(0 != rc))
    {
-      VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
-                "failed to acquire mutex, line [%d] in %s", __LINE__, __FUNCTION__);
-      return;     
+      mutex_unlock(&gpVosPacketContext->mlock);
+      return;
    }
 
    VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
@@ -526,10 +520,12 @@
       return VOS_STATUS_E_INVAL;
    }
 
+   mutex_lock(&gpVosPacketContext->mlock);
    (void) vos_pkti_list_destroy(&gpVosPacketContext->txMgmtFreeList);
    (void) vos_pkti_list_destroy(&gpVosPacketContext->txDataFreeList);
    (void) vos_pkti_list_destroy(&gpVosPacketContext->rxRawFreeList);
    (void) vos_pkti_list_destroy(&gpVosPacketContext->rxReplenishList);
+   mutex_unlock(&gpVosPacketContext->mlock);
 
 #ifdef WLAN_SOFTAP_FEATURE
    gpVosPacketContext->uctxDataFreeListCount = 0;
@@ -627,8 +623,6 @@
    struct list_head *pPktFreeList;
    vos_pkt_low_resource_info *pLowResourceInfo;
    struct vos_pkt_t *pVosPacket;
-   int rc; 
-
    // Validate the return parameter pointer
    if (unlikely(NULL == ppPacket))
    {
@@ -691,7 +685,7 @@
       return VOS_STATUS_E_ALREADY;
    }
 
-   rc = mutex_lock_interruptible(&gpVosPacketContext->mlock);
+   mutex_lock(&gpVosPacketContext->mlock);
    // are there vos packets on the associated free pool?
    if (unlikely(list_empty(pPktFreeList)))
    {
@@ -702,10 +696,7 @@
          VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
                    "VPKT [%d]: Low resource condition and no callback provided",
                    __LINE__);
-         if (likely(0 == rc)) 
-         {
-            mutex_unlock(&gpVosPacketContext->mlock);
-         }
+         mutex_unlock(&gpVosPacketContext->mlock);
 
          return VOS_STATUS_E_FAILURE;
       }
@@ -717,20 +708,15 @@
       VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_WARN,
                 "VPKT [%d]: Low resource condition for packet type %d[%s]",
                 __LINE__, pktType, vos_pkti_packet_type_str(pktType));
-      if (likely(0 == rc)) 
-      {
-         mutex_unlock(&gpVosPacketContext->mlock);
-      }
+      mutex_unlock(&gpVosPacketContext->mlock);
+
       return VOS_STATUS_E_RESOURCES;
    }
 
    // remove the first record from the free pool
    pVosPacket = list_first_entry(pPktFreeList, struct vos_pkt_t, node);
    list_del(&pVosPacket->node);
-   if (likely(0 == rc)) 
-   {
-      mutex_unlock(&gpVosPacketContext->mlock);
-   }
+   mutex_unlock(&gpVosPacketContext->mlock);
 
    // clear out the User Data pointers in the voss packet..
    memset(&pVosPacket->pvUserData, 0, sizeof(pVosPacket->pvUserData));
@@ -751,6 +737,7 @@
              0,
              skb_end_pointer(pVosPacket->pSkb) - pVosPacket->pSkb->head);
    }
+
    VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
              "VPKT [%d]: [%p] Packet allocated, type %d[%s]",
              __LINE__, pVosPacket, pktType, vos_pkti_packet_type_str(pktType));
@@ -1068,7 +1055,6 @@
                                   v_VOID_t **ppOSPacket,
                                   v_BOOL_t clearOSPacket )
 {
-
    // Validate the input and output parameter pointers
    if (unlikely((NULL == pPacket)||(NULL == ppOSPacket)))
    {
@@ -1265,7 +1251,6 @@
    vos_pkt_low_resource_info *pLowResourceInfo;
    vos_pkt_get_packet_callback callback;
    v_SIZE_t *pCount;
-   int rc; 
    VOS_PKT_TYPE packetType = VOS_PKT_TYPE_TX_802_3_DATA;
 
    // Validate the input parameter pointer
@@ -1288,6 +1273,7 @@
                    "VPKT [%d]: Invalid magic", __LINE__);
          return VOS_STATUS_E_INVAL;
       }
+
       //If an skb is attached then reset the pointers      
       if (pPacket->pSkb)
       {
@@ -1356,6 +1342,7 @@
                    "VPKT [%d]: [%p] Packet recycled, type %d[%s]",
                    __LINE__, pPacket, pPacket->packetType,
                    vos_pkti_packet_type_str(pPacket->packetType));
+
          // clear out the User Data pointers in the voss packet..
          memset(&pPacket->pvUserData, 0, sizeof(pPacket->pvUserData));
 
@@ -1377,13 +1364,10 @@
                    "VPKT [%d]: [%p] Packet returned, type %d[%s]",
                    __LINE__, pPacket, pPacket->packetType,
                    vos_pkti_packet_type_str(pPacket->packetType));
-
-         rc = mutex_lock_interruptible(&gpVosPacketContext->mlock);
+         mutex_lock(&gpVosPacketContext->mlock);
          list_add_tail(&pPacket->node, pPktFreeList);
-         if (likely(0 == rc)) 
-         {
-            mutex_unlock(&gpVosPacketContext->mlock);
-         }
+         mutex_unlock(&gpVosPacketContext->mlock);
+        
          if (pCount)
          {
             (*pCount)++;
@@ -2885,7 +2869,6 @@
    struct list_head *pList;
    struct list_head *pNode;
    v_SIZE_t count;
-   int rc; 
    if (NULL == vosFreeBuffer)
    {
       return VOS_STATUS_E_INVAL;
@@ -2923,15 +2906,12 @@
    }
 
    count = 0;
-   rc = mutex_lock_interruptible(&gpVosPacketContext->mlock);
+   mutex_lock(&gpVosPacketContext->mlock);
    list_for_each(pNode, pList)
    {
       count++;
    }
-   if (likely(0 == rc))
-   {
-      mutex_unlock(&gpVosPacketContext->mlock);
-   }
+   mutex_unlock(&gpVosPacketContext->mlock);
    *vosFreeBuffer = count;
    return VOS_STATUS_SUCCESS;
 }