Skip to content

Commit 2fe97a5

Browse files
Tung Nguyendavem330
authored andcommitted
tipc: fix potential memory leak in __tipc_sendmsg()
When initiating a connection message to a server side, the connection message is cloned and added to the socket write queue. However, if the cloning is failed, only the socket write queue is purged. It causes memory leak because the original connection message is not freed. This commit fixes it by purging the list of connection message when it cannot be cloned. Fixes: 6787927 ("tipc: buffer overflow handling in listener socket") Reported-by: Hoang Le <[email protected]> Signed-off-by: Tung Nguyen <[email protected]> Acked-by: Ying Xue <[email protected]> Acked-by: Jon Maloy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 61183b0 commit 2fe97a5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

net/tipc/socket.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1447,8 +1447,10 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen)
14471447
rc = tipc_msg_build(hdr, m, 0, dlen, mtu, &pkts);
14481448
if (unlikely(rc != dlen))
14491449
return rc;
1450-
if (unlikely(syn && !tipc_msg_skb_clone(&pkts, &sk->sk_write_queue)))
1450+
if (unlikely(syn && !tipc_msg_skb_clone(&pkts, &sk->sk_write_queue))) {
1451+
__skb_queue_purge(&pkts);
14511452
return -ENOMEM;
1453+
}
14521454

14531455
trace_tipc_sk_sendmsg(sk, skb_peek(&pkts), TIPC_DUMP_SK_SNDQ, " ");
14541456
rc = tipc_node_xmit(net, &pkts, dnode, tsk->portid);

0 commit comments

Comments
 (0)