From owner-svn-src-stable-10@freebsd.org Fri Sep 23 08:35:57 2016 Return-Path: Delivered-To: svn-src-stable-10@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 BAACDBE6037; Fri, 23 Sep 2016 08:35:57 +0000 (UTC) (envelope-from hselasky@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 8A6E91A4; Fri, 23 Sep 2016 08:35:57 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u8N8Zu6J056686; Fri, 23 Sep 2016 08:35:56 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u8N8ZuSg056685; Fri, 23 Sep 2016 08:35:56 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201609230835.u8N8ZuSg056685@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Fri, 23 Sep 2016 08:35:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r306254 - stable/10/sys/dev/mlx5/mlx5_en X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Sep 2016 08:35:57 -0000 Author: hselasky Date: Fri Sep 23 08:35:56 2016 New Revision: 306254 URL: https://svnweb.freebsd.org/changeset/base/306254 Log: MFC r305877: mlx5en: Fix duplicate mbuf free-by-code. When mlx5e_sq_xmit() returns an error code and the mbuf pointer is set, we should not free the mbuf, because the caller will keep the mbuf in the drbr. Make sure the mbuf pointer is correctly set upon function exit. Sponsored by: Mellanox Technologies Modified: stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c ============================================================================== --- stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Fri Sep 23 08:35:11 2016 (r306253) +++ stable/10/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c Fri Sep 23 08:35:56 2016 (r306254) @@ -224,10 +224,8 @@ mlx5e_sq_xmit(struct mlx5e_sq *sq, struc /* Send one multi NOP message instead of many */ mlx5e_send_nop(sq, (pi + 1) * MLX5_SEND_WQEBB_NUM_DS); pi = ((~sq->pc) & sq->wq.sz_m1); - if (pi < (MLX5_SEND_WQE_MAX_WQEBBS - 1)) { - m_freem(mb); + if (pi < (MLX5_SEND_WQE_MAX_WQEBBS - 1)) return (ENOMEM); - } } /* Setup local variables */ @@ -338,10 +336,8 @@ mlx5e_sq_xmit(struct mlx5e_sq *sq, struc mb, segs, &nsegs, BUS_DMA_NOWAIT); } /* Catch errors */ - if (err != 0) { + if (err != 0) goto tx_drop; - } - *mbp = mb; for (x = 0; x != nsegs; x++) { if (segs[x].ds_len == 0) @@ -374,6 +370,7 @@ skip_dma: bus_dmamap_sync(sq->dma_tag, sq->mbuf[pi].dma_map, BUS_DMASYNC_PREWRITE); sq->stats.packets++; + *mbp = NULL; /* safety clear */ return (0); tx_drop: