tipc: fix wrong socket reference counter after tipc_sk_timeout() returns
authorTung Nguyen <tung.q.nguyen@dektech.com.au>
Thu, 28 Nov 2019 03:10:06 +0000 (10:10 +0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 26 Jan 2020 09:01:00 +0000 (10:01 +0100)
commit58e007884a7bf7ad34552f266e7bb51cc9a7273b
treea71d3817d4db61bb1d46a614103d794f0748eaaa
parent55a0b2c95fd47db2adfeae50840c4b3a87c56179
tipc: fix wrong socket reference counter after tipc_sk_timeout() returns

commit 91a4a3eb433e4d786420c41f3c08d1d16c605962 upstream.

When tipc_sk_timeout() is executed but user space is grabbing
ownership, this function rearms itself and returns. However, the
socket reference counter is not reduced. This causes potential
unexpected behavior.

This commit fixes it by calling sock_put() before tipc_sk_timeout()
returns in the above-mentioned case.

Fixes: afe8792fec69 ("tipc: refactor function tipc_sk_timeout()")
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