From owner-svn-src-head@freebsd.org Tue Jun 13 19:32:24 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DB691BFCD3D; Tue, 13 Jun 2017 19:32:24 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AC13164B76; Tue, 13 Jun 2017 19:32:24 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v5DJWNLU051346; Tue, 13 Jun 2017 19:32:23 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v5DJWNQk051345; Tue, 13 Jun 2017 19:32:23 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201706131932.v5DJWNQk051345@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Tue, 13 Jun 2017 19:32:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r319917 - head/sys/net X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jun 2017 19:32:25 -0000 Author: sbruno Date: Tue Jun 13 19:32:23 2017 New Revision: 319917 URL: https://svnweb.freebsd.org/changeset/base/319917 Log: Plug mbuf leak in the busdma path of iflib. Submitted by: Michael Tuexen Reported by: Drew Gallitin Modified: head/sys/net/iflib.c Modified: head/sys/net/iflib.c ============================================================================== --- head/sys/net/iflib.c Tue Jun 13 19:02:12 2017 (r319916) +++ head/sys/net/iflib.c Tue Jun 13 19:32:23 2017 (r319917) @@ -2880,8 +2880,8 @@ iflib_busdma_load_mbuf_sg(iflib_txq_t txq, bus_dma_tag if_ctx_t ctx; if_shared_ctx_t sctx; if_softc_ctx_t scctx; - int i, next, pidx, mask, err, maxsegsz, ntxd, count; - struct mbuf *m, *tmp, **ifsd_m, **mp; + int i, next, pidx, err, maxsegsz, ntxd, count; + struct mbuf *m, *tmp, **ifsd_m; m = *m0; @@ -2905,19 +2905,22 @@ iflib_busdma_load_mbuf_sg(iflib_txq_t txq, bus_dma_tag if (err) return (err); ifsd_flags[pidx] |= TX_SW_DESC_MAPPED; - i = 0; - next = pidx; - mask = (txq->ift_size-1); + count = 0; m = *m0; do { - mp = &ifsd_m[next]; - *mp = m; + if (__predict_false(m->m_len <= 0)) { + tmp = m; + m = m->m_next; + tmp->m_next = NULL; + m_free(tmp); + continue; + } + next = (pidx + count) & (ntxd-1); + MPASS(ifsd_m[next] == NULL); + ifsd_m[next] = m; + count++; + tmp = m; m = m->m_next; - if (__predict_false((*mp)->m_len == 0)) { - m_free(*mp); - *mp = NULL; - } else - next = (pidx + i) & (ntxd-1); } while (m != NULL); } else { int buflen, sgsize, max_sgsize;