Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754094AbbLOPMs (ORCPT ); Tue, 15 Dec 2015 10:12:48 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:35178 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752923AbbLOPMq (ORCPT ); Tue, 15 Dec 2015 10:12:46 -0500 Date: Tue, 15 Dec 2015 15:12:43 +0000 From: Ben Hutchings To: Greg Kroah-Hartman Cc: David Ahern , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Nikolay Aleksandrov , "David S. Miller" Message-ID: <20151215151243.GN28542@decadent.org.uk> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="oIlomvtVtXAVxSKT" Content-Disposition: inline In-Reply-To: <20151215054004.GA30221@kroah.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: ben@decadent.org.uk Subject: [PATCH 4.3] vrf: Fix memory leak on registration failure in vrf_newlink() X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on shadbolt.decadent.org.uk) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2378 Lines: 71 --oIlomvtVtXAVxSKT Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable The backported version of commit 7f109f7cc371 ("vrf: fix double free and memory corruption on register_netdevice failure") incorrectly removed a kfree() from the failure path as well as the free_netdev(). Add that back. Signed-off-by: Ben Hutchings --- drivers/net/vrf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c index c9e309c..6c25fd0 100644 --- a/drivers/net/vrf.c +++ b/drivers/net/vrf.c @@ -581,6 +581,7 @@ static int vrf_newlink(struct net *src_net, struct net_= device *dev, { struct net_vrf *vrf =3D netdev_priv(dev); struct net_vrf_dev *vrf_ptr; + int err; =20 if (!data || !data[IFLA_VRF_TABLE]) return -EINVAL; @@ -598,7 +599,10 @@ static int vrf_newlink(struct net *src_net, struct net= _device *dev, =20 rcu_assign_pointer(dev->vrf_ptr, vrf_ptr); =20 - return register_netdev(dev); + err =3D register_netdev(dev); + if (err) + kfree(vrf_ptr); + return err; } =20 static size_t vrf_nl_getsize(const struct net_device *dev) --oIlomvtVtXAVxSKT Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIVAwUBVnAt6ue/yOyVhhEJAQp0Dg/+PTr9eWpAcmvcjIeTV2JkJtQ4whtLjsZM RobZfiE5IlrlZb3T27ACWr122tQ7e9o9D4CyeGuEMNd1W+TFroQB3NeEnvlshI6Z A364eOJSlsSr3LupLBbMeJHdbhVfNBKBHvXsa30pexkBuY/qzUcLIxfeY4ifMjSL yVVWnGGOFt7ojmR50YqTLDTHlXi5Vbv0EymW9oiejHIatOg8uIj5ifQ35n9JBJRp OAwztKI6jpizC8ykR5JtjEmlq5UW0Arp7fa74GiXyzehmZd0Vwdww5o0ixNry1Td fcWJc5aPkMgV2gp5ERcn3KcVbUFnHIi5Pvs/rQWjuA76uBTgcFzaocd1SxrN3itj 69UtpJxIdQJSEMM+MPmf8mttvPhgMkxP07Z32SSHBS5c7ci0NZXCvWUmKewXCZT7 WqpGBms6/5y6B9i/KiAz1Cx3on0z5VfTjGXMkLrvcsQKblUDakx67YNk0UeOKvzt fibCtsGYl/dTAFzTgCoZ8RuGeDodV2o8/ILtWQE+Z9rzSyiuJDPii1YBZDqef5IH z0HxbGX+Lh3l70chOmGd6t7szCbQmi+3ZjYjJRkF3alnNQYhmUhLXEXEFqp2zbyC Ytj+aikUY9x4fRbsNllupqcXI+8yApVVeHYU/4sqdVmu4inMAL385xL3P6xbnRzV aRr2yz/WTuo= =o2Y+ -----END PGP SIGNATURE----- --oIlomvtVtXAVxSKT-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/