From mboxrd@z Thu Jan 1 00:00:00 1970 From: Florian Westphal Subject: Re: [PATCH net] rhashtable: fix a memory leak in alloc_bucket_locks() Date: Fri, 26 Aug 2016 18:18:41 +0200 Message-ID: <20160826161841.GA20794@breakpoint.cc> References: <544270328.2536943.1472154674747.JavaMail.zimbra@redhat.com> <1474737839.2538727.1472155133819.JavaMail.zimbra@redhat.com> <2107409749.2541400.1472156272168.JavaMail.zimbra@redhat.com> <1472226699.14381.186.camel@edumazet-glaptop3.roam.corp.google.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: David Miller , CAI Qian , Thomas Graf , Herbert Xu , Eric Dumazet , Network Development , Linus Torvalds , Florian Westphal To: Eric Dumazet Return-path: Received: from Chamillionaire.breakpoint.cc ([146.0.238.67]:54376 "EHLO Chamillionaire.breakpoint.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932184AbcHZQSy (ORCPT ); Fri, 26 Aug 2016 12:18:54 -0400 Content-Disposition: inline In-Reply-To: <1472226699.14381.186.camel@edumazet-glaptop3.roam.corp.google.com> Sender: netdev-owner@vger.kernel.org List-ID: Eric Dumazet wrote: > From: Eric Dumazet > > If vmalloc() was successful, do not attempt a kmalloc_array() > > Fixes: 4cf0b354d92e ("rhashtable: avoid large lock-array allocations") > Reported-by: CAI Qian > Signed-off-by: Eric Dumazet > Cc: Florian Westphal > --- > lib/rhashtable.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/lib/rhashtable.c b/lib/rhashtable.c > index 5ba520b544d7..56054e541a0f 100644 > --- a/lib/rhashtable.c > +++ b/lib/rhashtable.c > @@ -77,17 +77,18 @@ static int alloc_bucket_locks(struct rhashtable *ht, struct bucket_table *tbl, > size = min_t(unsigned int, size, tbl->size >> 1); > > if (sizeof(spinlock_t) != 0) { > + tbl->locks = NULL; > #ifdef CONFIG_NUMA > if (size * sizeof(spinlock_t) > PAGE_SIZE && > gfp == GFP_KERNEL) > tbl->locks = vmalloc(size * sizeof(spinlock_t)); > - else > #endif Argh. Thanks Eric for fixing this :-/