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:
sbruno 2016-04-18 20:33:44 +00:00
parent f78898772a
commit 6a3325bc68
4 changed files with 4 additions and 4 deletions

View File

@ -2092,7 +2092,7 @@ retry:
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 @@ retry:
}
/* 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 @@ retry:
}
/* 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);