Revert "tcp: call sock_orphan() before freeing socket in tcp_nuke_addr"
This reverts commit 3d78ff9df45c3028845c5cf6a05c9378e438f77f.
Although the standard is to detach sockets from process contexts prior
to freeing them, under some conditions doing this in tcp_nuke_addr()
will cause a null socket dereference in sk_wait_data(). To avoid this
scenario, it may be necessary to purge the sk_receive queue and place
additional checks to ensure a socket is orphaned only when it will be freed.
Change-Id: I880ea9e2cd259eebbc40a81a32b96b4af8c36f95
Signed-off-by: Osvaldo Banuelos <osvaldob@codeaurora.org>
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 2628937..b2b0e99 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -3443,10 +3443,7 @@
tcp_done(sk);
bh_unlock_sock(sk);
local_bh_enable();
- if (!sock_flag(sk, SOCK_DEAD)) {
- sock_orphan(sk);
- sock_put(sk);
- }
+ sock_put(sk);
goto restart;
}