summaryrefslogtreecommitdiff
path: root/net/tipc
diff options
context:
space:
mode:
authorHangyu Hua <hbh25y@gmail.com>2022-06-29 09:34:18 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-07-21 21:59:25 +0300
commit4919d82f7041157a421ca9bf39a78551d5ad8a1b (patch)
tree2522e7de527adb734e573d22ada1f4e3a85e4b70 /net/tipc
parent70d8aee1de6e1e332942d21b7ec0ef495e26934d (diff)
downloadlinux-4919d82f7041157a421ca9bf39a78551d5ad8a1b.tar.xz
net: tipc: fix possible refcount leak in tipc_sk_create()
[ Upstream commit 00aff3590fc0a73bddd3b743863c14e76fd35c0c ] Free sk in case tipc_sk_insert() fails. Signed-off-by: Hangyu Hua <hbh25y@gmail.com> Reviewed-by: Tung Nguyen <tung.q.nguyen@dektech.com.au> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net/tipc')
-rw-r--r--net/tipc/socket.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index d543c4556df2..58c4d61d603f 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -455,6 +455,7 @@ static int tipc_sk_create(struct net *net, struct socket *sock,
sock_init_data(sock, sk);
tipc_set_sk_state(sk, TIPC_OPEN);
if (tipc_sk_insert(tsk)) {
+ sk_free(sk);
pr_warn("Socket create failed; port number exhausted\n");
return -EINVAL;
}