]> git.itanic.dy.fi Git - linux-stable/commitdiff
net: tipc: fix possible refcount leak in tipc_sk_create()
authorHangyu Hua <hbh25y@gmail.com>
Wed, 29 Jun 2022 06:34:18 +0000 (14:34 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 21 Jul 2022 19:09:30 +0000 (21:09 +0200)
[ 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>
net/tipc/socket.c

index 6c18b4565ab5148bd84c58f26989dba0776470ee..8266452c143b473212e9c1c8996b4b41d231ab13 100644 (file)
@@ -453,6 +453,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;
        }