qcacmn: Track available ext descriptors in the pool

Check for available ext descriptors before accessing freelist.

Change-Id: Iaeea9c7b3b69d14d53bcc23054ebd309b8be2ea9
CRs-Fixed: 2148174
This commit is contained in:
Manjunathappa Prakash
2017-11-22 14:09:33 -08:00
committed by snandini
parent bd894b3bb9
commit 98b30de852

View File

@@ -368,9 +368,14 @@ struct dp_tx_ext_desc_elem_s *dp_tx_ext_desc_alloc(struct dp_soc *soc,
struct dp_tx_ext_desc_elem_s *c_elem;
TX_DESC_LOCK_LOCK(&soc->tx_ext_desc[desc_pool_id].lock);
if (soc->tx_ext_desc[desc_pool_id].num_free <= 0) {
TX_DESC_LOCK_UNLOCK(&soc->tx_ext_desc[desc_pool_id].lock);
return NULL;
}
c_elem = soc->tx_ext_desc[desc_pool_id].freelist;
soc->tx_ext_desc[desc_pool_id].freelist =
soc->tx_ext_desc[desc_pool_id].freelist->next;
soc->tx_ext_desc[desc_pool_id].num_free--;
TX_DESC_LOCK_UNLOCK(&soc->tx_ext_desc[desc_pool_id].lock);
return c_elem;
}
@@ -389,6 +394,7 @@ static inline void dp_tx_ext_desc_free(struct dp_soc *soc,
TX_DESC_LOCK_LOCK(&soc->tx_ext_desc[desc_pool_id].lock);
elem->next = soc->tx_ext_desc[desc_pool_id].freelist;
soc->tx_ext_desc[desc_pool_id].freelist = elem;
soc->tx_ext_desc[desc_pool_id].num_free++;
TX_DESC_LOCK_UNLOCK(&soc->tx_ext_desc[desc_pool_id].lock);
return;
}