From owner-freebsd-net@FreeBSD.ORG Tue Mar 18 12:46:50 2014 Return-Path: Delivered-To: net@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7F7D530C for ; Tue, 18 Mar 2014 12:46:50 +0000 (UTC) Received: from cell.glebius.int.ru (glebius.int.ru [81.19.69.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 046C3B8E for ; Tue, 18 Mar 2014 12:46:49 +0000 (UTC) Received: from cell.glebius.int.ru (localhost [127.0.0.1]) by cell.glebius.int.ru (8.14.8/8.14.8) with ESMTP id s2ICkOUC003846 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 18 Mar 2014 16:46:24 +0400 (MSK) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebius.int.ru (8.14.8/8.14.8/Submit) id s2ICkOOv003845; Tue, 18 Mar 2014 16:46:24 +0400 (MSK) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebius.int.ru: glebius set sender to glebius@FreeBSD.org using -f Date: Tue, 18 Mar 2014 16:46:24 +0400 From: Gleb Smirnoff To: Andrew Rybchenko Subject: Re: [PATCH 1/6] sfxge: fix mbuf leak if it does not fit in software queue Message-ID: <20140318124624.GD1499@FreeBSD.org> References: <53280DB3.4080900@oktetlabs.ru> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="T4sUOijqQbZv57TR" Content-Disposition: inline In-Reply-To: <53280DB3.4080900@oktetlabs.ru> User-Agent: Mutt/1.5.22 (2013-10-16) Cc: net@FreeBSD.org X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Mar 2014 12:46:50 -0000 --T4sUOijqQbZv57TR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Andrew, On Tue, Mar 18, 2014 at 01:11:15PM +0400, Andrew Rybchenko wrote: A> A> sfxge: fix mbuf leak if it does not fit in software queue A> A> mbuf should be owned by if_transmit function in any case. A> A> Submitted-by: Andrew Rybchenko A> Sponsored by: Solarflare Communications, Inc. Can we simplify the function while here? -- Totus tuus, Glebius. --T4sUOijqQbZv57TR Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="1.diff" Index: sfxge_tx.c =================================================================== --- sfxge_tx.c (revision 263296) +++ sfxge_tx.c (working copy) @@ -498,7 +498,6 @@ int sfxge_tx_packet_add(struct sfxge_txq *txq, struct mbuf *m) { int locked; - int rc; /* * Try to grab the txq lock. If we are able to get the lock, @@ -511,10 +510,9 @@ sfxge_tx_packet_add(struct sfxge_txq *txq, struct * Can only fail if we weren't able to get the lock. */ if (sfxge_tx_qdpl_put(txq, m, locked) != 0) { - KASSERT(!locked, - ("sfxge_tx_qdpl_put() failed locked")); - rc = ENOBUFS; - goto fail; + KASSERT(!locked, ("sfxge_tx_qdpl_put() failed locked")); + m_freem(m); + return (ENOBUFS); } /* @@ -534,10 +532,6 @@ sfxge_tx_packet_add(struct sfxge_txq *txq, struct } return (0); - -fail: - return (rc); - } static void --T4sUOijqQbZv57TR--