]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
af_unix: Fix memleak of newsk in unix_stream_connect().
authorKuniyuki Iwashima <kuniyu@google.com>
Sat, 7 Feb 2026 23:22:34 +0000 (23:22 +0000)
committerPaolo Abeni <pabeni@redhat.com>
Wed, 11 Feb 2026 12:01:13 +0000 (13:01 +0100)
commit6884028cd7f275f8bcb854a347265cb1fb0e4bea
treedc8a7f80388a9c992a66601dc7ad1364ef5d5dc5
parente3998b6e90f875f19bf758053d79ccfd41880173
af_unix: Fix memleak of newsk in unix_stream_connect().

When prepare_peercred() fails in unix_stream_connect(),
unix_release_sock() is not called for newsk, and the memory
is leaked.

Let's move prepare_peercred() before unix_create1().

Fixes: fd0a109a0f6b ("net, pidfs: prepare for handing out pidfds for reaped sk->sk_peer_pid")
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20260207232236.2557549-1-kuniyu@google.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/unix/af_unix.c