Subject: [PATCH] net: use get_random_u32() for net_namespace hash_mix initialization

From: David Carlier <[email-masked]>
Date: Fri, 3 Apr 2026 11:36:54 +0100

Use get_random_u32() instead of get_random_bytes() to initialize
net->hash_mix. This is the preferred API for obtaining a single
random u32 value, as it returns the value directly rather than
writing through a pointer, and requires no size parameter.

Signed-off-by: David Carlier <[email-masked]>
---
 net/core/net_namespace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 1057d16d5dd2..deb8b2ec5674 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -411,7 +411,7 @@ static __net_init int preinit_net(struct net *net, struct user_namespace *user_n
 	ref_tracker_dir_init(&net->refcnt_tracker, 128, "net_refcnt");
 	ref_tracker_dir_init(&net->notrefcnt_tracker, 128, "net_notrefcnt");
 
-	get_random_bytes(&net->hash_mix, sizeof(u32));
+	net->hash_mix = get_random_u32();
 	net->dev_base_seq = 1;
 	net->user_ns = user_ns;
 
-- 
2.53.0