[PATCH 1/6] sock: add sock_kzalloc helper

Thorsten Blum
2026-04-27T10:43:52Z

Add sock_kzalloc() helper - the sock equivalent to kzalloc().

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
include/net/sock.h | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/include/net/sock.h b/include/net/sock.h
index dccd3738c368..20bf406dff2d 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1904,6 +1904,11 @@ void sock_kfree_s(struct sock *sk, void *mem, int size);
void sock_kzfree_s(struct sock *sk, void *mem, int size);
void sk_send_sigurg(struct sock *sk);

+static inline void *sock_kzalloc(struct sock *sk, int size, gfp_t priority)
+{
+ return sock_kmalloc(sk, size, priority | __GFP_ZERO);
+}
+
static inline void sock_replace_proto(struct sock *sk, struct proto *proto)
{
if (sk->sk_socket)