netrom: Fix sock_orphan() use in nr_release

Message ID 20081005221648.GB2613@ami.dom.local
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Jarek Poplawski Oct. 5, 2008, 10:16 p.m.
netrom: Fix sock_orphan() use in nr_release

While debugging another bug it was found that NetRom socks
are sometimes seen unorphaned in sk_free(). This patch moves
sock_orphan() in nr_release() to the beginning (like in ax25,
or rose).

Reported-and-tested-by: Bernard Pidoux f6bvp <>
Signed-off-by: Jarek Poplawski <>


 net/netrom/af_netrom.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to
More majordomo info at


diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
index 532e4fa..9f1ea4a 100644
--- a/net/netrom/af_netrom.c
+++ b/net/netrom/af_netrom.c
@@ -525,6 +525,7 @@  static int nr_release(struct socket *sock)
 	if (sk == NULL) return 0;
+	sock_orphan(sk);
 	nr = nr_sk(sk);
@@ -548,7 +549,6 @@  static int nr_release(struct socket *sock)
 		sk->sk_state    = TCP_CLOSE;
 		sk->sk_shutdown |= SEND_SHUTDOWN;
-		sock_orphan(sk);
 		sock_set_flag(sk, SOCK_DESTROY);