LE: Release transmit buffer credits

When an ACL link goes down, some controllers do not send a "number of
completed packets" update for the last ACL packets sent from the host to
the controller. This could result in incorrect L2CAP transmit window
calculations and no transmit credit to be available to send data to the
controller.
This patch restores transmit buffer creedits regardless of the
controller behaviour.
bug 9474159

Change-Id: I2540131034271a0269fa50698f370bceb7747e2d
diff --git a/stack/l2cap/l2c_utils.c b/stack/l2cap/l2c_utils.c
index b911db2..457ea2d 100644
--- a/stack/l2cap/l2c_utils.c
+++ b/stack/l2cap/l2c_utils.c
@@ -136,6 +136,28 @@
     btm_remove_sco_links(p_lcb->remote_bd_addr);
 #endif
 
+    if (p_lcb->sent_not_acked > 0)
+    {
+#if (BLE_INCLUDED == TRUE)
+        if (p_lcb->is_ble_link)
+        {
+            l2cb.controller_le_xmit_window += p_lcb->sent_not_acked;
+            if (l2cb.controller_le_xmit_window > l2cb.num_lm_ble_bufs)
+            {
+                l2cb.controller_le_xmit_window = l2cb.num_lm_ble_bufs;
+            }
+        }
+        else
+#endif
+        {
+            l2cb.controller_xmit_window += p_lcb->sent_not_acked;
+            if (l2cb.controller_xmit_window > l2cb.num_lm_acl_bufs)
+            {
+                l2cb.controller_xmit_window = l2cb.num_lm_acl_bufs;
+            }
+        }
+    }
+
 #if (BLE_INCLUDED == TRUE)
     p_lcb->is_ble_link = FALSE;
     l2cb.is_ble_connecting = FALSE;
@@ -183,15 +205,6 @@
     if (l2cb.num_links_active >= 1)
         l2cb.num_links_active--;
 
-    if (p_lcb->sent_not_acked > 0)
-    {
-        l2cb.controller_xmit_window += p_lcb->sent_not_acked;
-        if (l2cb.controller_xmit_window > l2cb.num_lm_acl_bufs)
-        {
-            l2cb.controller_xmit_window = l2cb.num_lm_acl_bufs;
-        }
-    }
-
     l2c_link_adjust_allocation();
 
     /* Check for ping outstanding */