summaryrefslogtreecommitdiff
path: root/net/tipc/socket.c
diff options
context:
space:
mode:
authorHangyu Hua <hbh25y@gmail.com>2022-06-29 14:34:18 +0800
committerDavid S. Miller <davem@davemloft.net>2022-06-29 13:49:06 +0100
commit00aff3590fc0a73bddd3b743863c14e76fd35c0c (patch)
tree3f65507f2ff0bcea5b8c57dfbbee5baa811d8aeb /net/tipc/socket.c
parent5a478a653b4cca148d5c89832f007ec0809d7e6d (diff)
net: tipc: fix possible refcount leak in tipc_sk_create()
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>
Diffstat (limited to 'net/tipc/socket.c')
-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 17f8c523e33b..43509c7e90fc 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -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;
}