]> git.baikalelectronics.ru Git - kernel.git/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)
committerDavid S. Miller <davem@davemloft.net>
Wed, 29 Jun 2022 12:49:06 +0000 (13:49 +0100)
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>
net/tipc/socket.c

index 17f8c523e33b04d4f867315c4db7092a42f2574d..43509c7e90fc2827110fd55cc98506b493951035 100644 (file)
@@ -502,6 +502,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;
        }