From: Hangyu Hua Date: Wed, 29 Jun 2022 06:34:18 +0000 (+0800) Subject: net: tipc: fix possible refcount leak in tipc_sk_create() X-Git-Tag: v6.1-rc5~973^2~17 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=00aff3590fc0a73bddd3b743863c14e76fd35c0c;p=platform%2Fkernel%2Flinux-starfive.git net: tipc: fix possible refcount leak in tipc_sk_create() Free sk in case tipc_sk_insert() fails. Signed-off-by: Hangyu Hua Reviewed-by: Tung Nguyen Signed-off-by: David S. Miller --- diff --git a/net/tipc/socket.c b/net/tipc/socket.c index 17f8c52..43509c7 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; }