Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 Jun 2014 17:34:09 +0000 (UTC)
From:      Navdeep Parhar <np@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r266973 - stable/9/sys/dev/cxgbe
Message-ID:  <201406021734.s52HY9fX030836@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: np
Date: Mon Jun  2 17:34:08 2014
New Revision: 266973
URL: http://svnweb.freebsd.org/changeset/base/266973

Log:
  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.
  
  Approved by:	re (glebius)

Modified:
  stable/9/sys/dev/cxgbe/t4_sge.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/cxgbe/t4_sge.c
==============================================================================
--- stable/9/sys/dev/cxgbe/t4_sge.c	Mon Jun  2 15:05:25 2014	(r266972)
+++ stable/9/sys/dev/cxgbe/t4_sge.c	Mon Jun  2 17:34:08 2014	(r266973)
@@ -1536,6 +1536,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);
 
@@ -1559,6 +1560,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) {
@@ -1570,7 +1573,8 @@ get_segment:
 			fl->m0 = m0;
 			fl->pnext = pnext;
 			fl->remaining = len;
-			return (NULL);
+			m0 = NULL;
+			goto done;
 		}
 		*pnext = m;
 		pnext = &m->m_next;
@@ -1579,7 +1583,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?201406021734.s52HY9fX030836>