[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170427101305.GA1701@gondor.apana.org.au>
Date: Thu, 27 Apr 2017 18:13:05 +0800
From: Herbert Xu <herbert@...dor.apana.org.au>
To: Florian Westphal <fw@...len.de>
Cc: David Miller <davem@...emloft.net>, netdev@...r.kernel.org,
Thomas Graf <tgraf@...g.ch>
Subject: Re: rhashtable - Cap total number of entries to 2^31
On Thu, Apr 27, 2017 at 12:11:34PM +0200, Florian Westphal wrote:
>
> > + /* Cap total entries at 2^31 to avoid nelems overflow. */
> > + ht->max_elems = 1u << 31;
> > + if (ht->p.max_size < ht->max_elems / 2)
> > + ht->max_elems = ht->p.max_size * 2;
> > +
>
> Looks like instead of adding this max_elems you could instead have fixed this via
>
> if (!ht->p.max_size)
> ht->p.max_size = INT_MAX / 2;
>
> if (ht->p.max_size > INT_MAX / 2)
> return -EINVAL;
No that doesn't do the same thing. Setting max_size caps the table
size and I don't want to do that at all.
Cheers,
--
Email: Herbert Xu <herbert@...dor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Powered by blists - more mailing lists