Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933598AbbLOPPP (ORCPT ); Tue, 15 Dec 2015 10:15:15 -0500 Received: from mail-pf0-f169.google.com ([209.85.192.169]:32836 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932734AbbLOPPN (ORCPT ); Tue, 15 Dec 2015 10:15:13 -0500 Subject: Re: [PATCH 4.3] vrf: Fix memory leak on registration failure in vrf_newlink() To: Ben Hutchings , Greg Kroah-Hartman References: <20151215151243.GN28542@decadent.org.uk> Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Nikolay Aleksandrov , "David S. Miller" From: David Ahern Message-ID: <56702E7E.5000604@cumulusnetworks.com> Date: Tue, 15 Dec 2015 08:15:10 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <20151215151243.GN28542@decadent.org.uk> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 729 Lines: 24 On 12/15/15 8:12 AM, Ben Hutchings wrote: > @@ -598,7 +599,10 @@ static int vrf_newlink(struct net *src_net, struct net_device *dev, > > rcu_assign_pointer(dev->vrf_ptr, vrf_ptr); > > - return register_netdev(dev); > + err = register_netdev(dev); > + if (err) > + kfree(vrf_ptr); > + return err; > } > > static size_t vrf_nl_getsize(const struct net_device *dev) > The rcu_assign_pointer should only be done if the register_netdev succeeded. Thanks for creating the patch. -- 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/