Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 May 2014 22:59:46 +0000 (UTC)
From:      Navdeep Parhar <np@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r266908 - head/sys/dev/cxgbe
Message-ID:  <201405302259.s4UMxkwp028795@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201405302259.s4UMxkwp028795>