From owner-svn-src-head@freebsd.org Wed Apr 5 19:52:50 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 8EDF8D2F2D7; Wed, 5 Apr 2017 19:52:50 +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 4209B93D; Wed, 5 Apr 2017 19:52:50 +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 v35Jqno6039035; Wed, 5 Apr 2017 19:52:49 GMT (envelope-from sbruno@FreeBSD.org) Received: (from sbruno@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v35JqnLp039034; Wed, 5 Apr 2017 19:52:49 GMT (envelope-from sbruno@FreeBSD.org) Message-Id: <201704051952.v35JqnLp039034@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sbruno set sender to sbruno@FreeBSD.org using -f From: Sean Bruno Date: Wed, 5 Apr 2017 19:52:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r316541 - head/sys/dev/ixgbe 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: Wed, 05 Apr 2017 19:52:50 -0000 Author: sbruno Date: Wed Apr 5 19:52:49 2017 New Revision: 316541 URL: https://svnweb.freebsd.org/changeset/base/316541 Log: Fix a double free in ixgbe_rxeof() Submitted by: rstone MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D10255 Modified: head/sys/dev/ixgbe/ix_txrx.c Modified: head/sys/dev/ixgbe/ix_txrx.c ============================================================================== --- head/sys/dev/ixgbe/ix_txrx.c Wed Apr 5 19:46:24 2017 (r316540) +++ head/sys/dev/ixgbe/ix_txrx.c Wed Apr 5 19:52:49 2017 (r316541) @@ -1431,20 +1431,10 @@ fail: static void ixgbe_free_receive_ring(struct rx_ring *rxr) -{ - struct ixgbe_rx_buf *rxbuf; +{ for (int i = 0; i < rxr->num_desc; i++) { - rxbuf = &rxr->rx_buffers[i]; - if (rxbuf->buf != NULL) { - bus_dmamap_sync(rxr->ptag, rxbuf->pmap, - BUS_DMASYNC_POSTREAD); - bus_dmamap_unload(rxr->ptag, rxbuf->pmap); - rxbuf->buf->m_flags |= M_PKTHDR; - m_freem(rxbuf->buf); - rxbuf->buf = NULL; - rxbuf->flags = 0; - } + ixgbe_rx_discard(rxr, i); } } @@ -1596,7 +1586,9 @@ fail: */ for (int i = 0; i < j; ++i) { rxr = &adapter->rx_rings[i]; + IXGBE_RX_LOCK(rxr); ixgbe_free_receive_ring(rxr); + IXGBE_RX_UNLOCK(rxr); } return (ENOBUFS); @@ -1645,14 +1637,7 @@ ixgbe_free_receive_buffers(struct rx_rin if (rxr->rx_buffers != NULL) { for (int i = 0; i < adapter->num_rx_desc; i++) { rxbuf = &rxr->rx_buffers[i]; - if (rxbuf->buf != NULL) { - bus_dmamap_sync(rxr->ptag, rxbuf->pmap, - BUS_DMASYNC_POSTREAD); - bus_dmamap_unload(rxr->ptag, rxbuf->pmap); - rxbuf->buf->m_flags |= M_PKTHDR; - m_freem(rxbuf->buf); - } - rxbuf->buf = NULL; + ixgbe_rx_discard(rxr, i); if (rxbuf->pmap != NULL) { bus_dmamap_destroy(rxr->ptag, rxbuf->pmap); rxbuf->pmap = NULL; @@ -1722,11 +1707,12 @@ ixgbe_rx_discard(struct rx_ring *rxr, in */ if (rbuf->fmp != NULL) {/* Partial chain ? */ - rbuf->fmp->m_flags |= M_PKTHDR; + bus_dmamap_sync(rxr->ptag, rbuf->pmap, BUS_DMASYNC_POSTREAD); m_freem(rbuf->fmp); rbuf->fmp = NULL; rbuf->buf = NULL; /* rbuf->buf is part of fmp's chain */ } else if (rbuf->buf) { + bus_dmamap_sync(rxr->ptag, rbuf->pmap, BUS_DMASYNC_POSTREAD); m_free(rbuf->buf); rbuf->buf = NULL; } @@ -1814,6 +1800,8 @@ ixgbe_rxeof(struct ix_queue *que) goto next_desc; } + bus_dmamap_sync(rxr->ptag, rbuf->pmap, BUS_DMASYNC_POSTREAD); + /* ** On 82599 which supports a hardware ** LRO (called HW RSC), packets need