tipc: fix potential memory leak in __tipc_sendmsg()
authorTung Nguyen <tung.q.nguyen@dektech.com.au>
Thu, 28 Nov 2019 03:10:05 +0000 (10:10 +0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 26 Jan 2020 09:01:00 +0000 (10:01 +0100)
commit55a0b2c95fd47db2adfeae50840c4b3a87c56179
treedc1c772046d01f659cd97b282648259a9ec7e78c
parent28845c28f842e9e55e75b2c116bff714bb039055
tipc: fix potential memory leak in __tipc_sendmsg()

commit 2fe97a578d7bad3116a89dc8a6692a51e6fc1d9c upstream.

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: 6787927475e5 ("tipc: buffer overflow handling in listener socket")
Reported-by: Hoang Le <hoang.h.le@dektech.com.au>
Signed-off-by: Tung Nguyen <tung.q.nguyen@dektech.com.au>
Acked-by: Ying Xue <ying.xue@windriver.com>
Acked-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/tipc/socket.c