diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2022-10-05 17:23:53 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2022-10-11 17:42:58 -0600 |
commit | f743f16c548b1a2633e8b6034058d6475d7f26a3 (patch) | |
tree | c163930a1808d49fcb6bdcb897f88e3a7f8dc62e /net/rds/bind.c | |
parent | 7e3cf0843fe505491baa05e355e83e6997e089dd (diff) | |
download | linux-f743f16c548b1a2633e8b6034058d6475d7f26a3.tar.gz |
treewide: use get_random_{u8,u16}() when possible, part 2
Rather than truncate a 32-bit value to a 16-bit value or an 8-bit value,
simply use the get_random_{u8,u16}() functions, which are faster than
wasting the additional bytes from a 32-bit value. This was done by hand,
identifying all of the places where one of the random integer functions
was used in a non-32-bit context.
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Yury Norov <yury.norov@gmail.com>
Acked-by: Jakub Kicinski <kuba@kernel.org>
Acked-by: Heiko Carstens <hca@linux.ibm.com> # for s390
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'net/rds/bind.c')
-rw-r--r-- | net/rds/bind.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/net/rds/bind.c b/net/rds/bind.c index 5b5fb4ca8d3e..97a29172a8ee 100644 --- a/net/rds/bind.c +++ b/net/rds/bind.c @@ -104,7 +104,7 @@ static int rds_add_bound(struct rds_sock *rs, const struct in6_addr *addr, return -EINVAL; last = rover; } else { - rover = max_t(u16, prandom_u32(), 2); + rover = max_t(u16, get_random_u16(), 2); last = rover - 1; } |