Correct possible underflow conditions when checking for available space

in the tx h/w ring buffer.

Reviewed by:	gnn jeb.j.cramer@intel.com
MFC after:	1 week
Sponsored by:	Limelight Networks
Differential Revision:	https://reviews.freebsd.org/D5918
This commit is contained in:
Sean Bruno 2016-04-18 20:33:44 +00:00
parent b1deed45e6
commit ae6bd5b7be
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=298224
4 changed files with 4 additions and 4 deletions

View File

@ -2092,7 +2092,7 @@ em_xmit(struct tx_ring *txr, struct mbuf **m_headp)
txr->tx_tso = FALSE;
}
if (nsegs > (txr->tx_avail - EM_MAX_SCATTER)) {
if (txr->tx_avail < (nsegs + EM_MAX_SCATTER)) {
txr->no_desc_avail++;
bus_dmamap_unload(txr->txtag, map);
return (ENOBUFS);

View File

@ -1887,7 +1887,7 @@ igb_xmit(struct tx_ring *txr, struct mbuf **m_headp)
}
/* Make certain there are enough descriptors */
if (nsegs > txr->tx_avail - 2) {
if (txr->tx_avail < (nsegs + 2)) {
txr->no_desc_avail++;
bus_dmamap_unload(txr->txtag, map);
return (ENOBUFS);

View File

@ -1699,7 +1699,7 @@ lem_xmit(struct adapter *adapter, struct mbuf **m_headp)
return (error);
}
if (nsegs > (adapter->num_tx_desc_avail - 2)) {
if (adapter->num_tx_desc_avail < (nsegs + 2)) {
adapter->no_tx_desc_avail2++;
bus_dmamap_unload(adapter->txtag, map);
return (ENOBUFS);

View File

@ -402,7 +402,7 @@ ixgbe_xmit(struct tx_ring *txr, struct mbuf **m_headp)
}
/* Make certain there are enough descriptors */
if (nsegs > txr->tx_avail - 2) {
if (txr->tx_avail < (nsegs + 2)) {
txr->no_desc_avail++;
bus_dmamap_unload(txr->txtag, map);
return (ENOBUFS);