From: Eric Biggers <ebiggers@kernel.org>
To: Satya Tangirala <satyat@google.com>
Cc: Christoph Hellwig <hch@infradead.org>,
linux-block@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
linux-fscrypt@vger.kernel.org
Subject: Re: [PATCH] block/keyslot-manager: prevent crash when num_slots=1
Date: Wed, 11 Nov 2020 11:25:39 -0800 [thread overview]
Message-ID: <20201111192539.GB335825@gmail.com> (raw)
In-Reply-To: <20201111094538.GA3907007@google.com>
On Wed, Nov 11, 2020 at 09:45:38AM +0000, Satya Tangirala wrote:
> On Wed, Nov 11, 2020 at 09:23:05AM +0000, Christoph Hellwig wrote:
> > On Tue, Nov 10, 2020 at 06:14:27PM -0800, Eric Biggers wrote:
> > > + * hash_ptr() assumes bits != 0, so ensure the hash table has at least 2
> > > + * buckets. This only makes a difference when there is only 1 keyslot.
> > > + */
> > > + slot_hashtable_size = max(slot_hashtable_size, 2U);
> >
> > shouldn't this be a min()?
> I think it should be max(), since we want whichever is larger between 2
> and the original slot_hashtable_size :)
max() is correct. I could just open-code it, if that would make it clearer:
/*
* hash_ptr() assumes bits != 0, so ensure the hash table has at least 2
* buckets. This only makes a difference when there is only 1 keyslot.
*/
if (slot_hashtable_size < 2)
slot_hashtable_size = 2;
next prev parent reply other threads:[~2020-11-11 19:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-11 2:14 [PATCH] block/keyslot-manager: prevent crash when num_slots=1 Eric Biggers
2020-11-11 9:23 ` Christoph Hellwig
2020-11-11 9:45 ` Satya Tangirala
2020-11-11 19:25 ` Eric Biggers [this message]
2020-11-11 21:50 ` Eric Biggers
2020-11-16 16:34 ` Christoph Hellwig
2020-11-11 9:49 ` Satya Tangirala
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201111192539.GB335825@gmail.com \
--to=ebiggers@kernel.org \
--cc=axboe@kernel.dk \
--cc=hch@infradead.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=satyat@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox