From: "Gustavo A. R. Silva" <gustavoars@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: linux-hardening@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>
Subject: [PATCH 3/3][next] lib/stackdepot.c: Use array_size() helper in jhash2()
Date: Thu, 1 Oct 2020 10:26:34 -0500 [thread overview]
Message-ID: <cb8a682e4bba4dbddd2bd8aca7f8c02fea89639b.1601565471.git.gustavoars@kernel.org> (raw)
In-Reply-To: <cover.1601565471.git.gustavoars@kernel.org>
Use array_size() helper instead of the open-coded version in jhash2().
These sorts of multiplication factors need to be wrapped in array_size().
Also, use the preferred form for passing the size of an object type.
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
lib/stackdepot.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/stackdepot.c b/lib/stackdepot.c
index 683b6a8ddade..890dcc2e984e 100644
--- a/lib/stackdepot.c
+++ b/lib/stackdepot.c
@@ -154,8 +154,8 @@ static struct stack_record *stack_table[STACK_HASH_SIZE] = {
static inline u32 hash_stack(unsigned long *entries, unsigned int size)
{
return jhash2((u32 *)entries,
- size * sizeof(unsigned long) / sizeof(u32),
- STACK_HASH_SEED);
+ array_size(size, sizeof(*entries)) / sizeof(u32),
+ STACK_HASH_SEED);
}
/* Use our own, non-instrumented version of memcmp().
--
2.27.0
prev parent reply other threads:[~2020-10-01 15:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-01 15:24 [PATCH 0/3][next] lib/stackdepot.c: Replace one-element array with flexible-array member Gustavo A. R. Silva
2020-10-01 15:25 ` [PATCH 1/3][next] " Gustavo A. R. Silva
2020-10-01 15:25 ` [PATCH 2/3][next] lib/stackdepot.c: Use flex_array_size() helper in memcpy() Gustavo A. R. Silva
2020-10-01 15:26 ` Gustavo A. R. Silva [this message]
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=cb8a682e4bba4dbddd2bd8aca7f8c02fea89639b.1601565471.git.gustavoars@kernel.org \
--to=gustavoars@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®