MFC r266908:

cxgbe(4): Fix a NULL dereference when the very first call to
get_scatter_segment() in get_fl_payload() fails.  While here,
fix the code to adjust fl_bufs_used when a failure occurs for
any other scatter segment.
This commit is contained in:
np 2014-06-02 05:01:08 +00:00
parent 5b93c96241
commit 7bdc535062

View File

@ -1565,6 +1565,7 @@ get_fl_payload(struct adapter *sc, struct sge_fl *fl, uint32_t len_newbuf,
nbuf = 0;
len = G_RSPD_LEN(len_newbuf);
if (__predict_false(fl->m0 != NULL)) {
M_ASSERTPKTHDR(fl->m0);
MPASS(len == fl->m0->m_pkthdr.len);
MPASS(fl->remaining < len);
@ -1588,6 +1589,8 @@ get_fl_payload(struct adapter *sc, struct sge_fl *fl, uint32_t len_newbuf,
*/
m0 = get_scatter_segment(sc, fl, len, M_PKTHDR);
if (m0 == NULL)
goto done;
len -= m0->m_len;
pnext = &m0->m_next;
while (len > 0) {
@ -1599,7 +1602,8 @@ get_fl_payload(struct adapter *sc, struct sge_fl *fl, uint32_t len_newbuf,
fl->m0 = m0;
fl->pnext = pnext;
fl->remaining = len;
return (NULL);
m0 = NULL;
goto done;
}
*pnext = m;
pnext = &m->m_next;
@ -1608,7 +1612,7 @@ get_fl_payload(struct adapter *sc, struct sge_fl *fl, uint32_t len_newbuf,
*pnext = NULL;
if (fl->rx_offset == 0)
nbuf++;
done:
(*fl_bufs_used) += nbuf;
return (m0);
}