Skip to contentSkip to conversation

net: tipc: fix possible refcount leak in tipc_sk_create()

PATCH Applied Hangyu Hua 3 participants 3 messages Jun 29, 2022

Subsystems (3)
lore
Share & tools
lore

Hangyu Hua

author
#0 lore raw

PATCH v2 1/1 net: tipc: fix possible refcount leak in tipc_sk_create()

Free sk in case tipc_sk_insert() fails.

---

v2: use a succinct commit log.

 net/tipc/socket.c | 1 +
 1 file changed, 1 insertion(+)
net/tipc/socket.c +1 -0
index 17f8c523e33b..43509c7e90fc 100644
@@ -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;
 	}
Signature · 1 line
2.25.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 25 lines

Subject: [PATCH v2] net: tipc: fix possible refcount leak in tipc_sk_create()

Free sk in case tipc_sk_insert() fails.

---

v2: use a succinct commit log.

 net/tipc/socket.c | 1 +
 1 file changed, 1 insertion(+)
net/tipc/socket.c +1 -1
index 17f8c523e33b..43509c7e90fc 100644
@@ -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;
 	}
--
Quoted 1 line

2.25.1

#2 lore raw
In reply to Hangyu Hua
This patch was applied to netdev/net.git (master) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <[email protected]>:

Quoted 8 lines · On Wed, 29 Jun 2022 14:34:18 +0800 you wrote:

Free sk in case tipc_sk_insert() fails.

---

v2: use a succinct commit log.

[...]

Here is the summary with links:
- [v2] net: tipc: fix possible refcount leak in tipc_sk_create()

    https://git.kernel.org/netdev/net/c/00aff3590fc0

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html