svn commit: r266908 - head/sys/dev/cxgbe

Navdeep Parhar np at FreeBSD.org
Fri May 30 22:59:46 UTC 2014


Author: np
Date: Fri May 30 22:59:45 2014
New Revision: 266908
URL: http://svnweb.freebsd.org/changeset/base/266908

Log:
  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.
  
  MFC after:	3 days

Modified:
  head/sys/dev/cxgbe/t4_sge.c

Modified: head/sys/dev/cxgbe/t4_sge.c
==============================================================================
--- head/sys/dev/cxgbe/t4_sge.c	Fri May 30 22:34:06 2014	(r266907)
+++ head/sys/dev/cxgbe/t4_sge.c	Fri May 30 22:59:45 2014	(r266908)
@@ -1628,6 +1628,7 @@ get_fl_payload(struct adapter *sc, struc
 	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);
 
@@ -1651,6 +1652,8 @@ get_fl_payload(struct adapter *sc, struc
 	 */
 
 	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) {
@@ -1662,7 +1665,8 @@ get_segment:
 			fl->m0 = m0;
 			fl->pnext = pnext;
 			fl->remaining = len;
-			return (NULL);
+			m0 = NULL;
+			goto done;
 		}
 		*pnext = m;
 		pnext = &m->m_next;
@@ -1671,7 +1675,7 @@ get_segment:
 	*pnext = NULL;
 	if (fl->rx_offset == 0)
 		nbuf++;
-
+done:
 	(*fl_bufs_used) += nbuf;
 	return (m0);
 }


More information about the svn-src-head mailing list