appletalk: Fix OOPS in atalk_release().
[linux-2.6.git] / net / appletalk / ddp.c
index 206e771..956a530 100644 (file)
@@ -1051,16 +1051,17 @@ static int atalk_release(struct socket *sock)
 {
        struct sock *sk = sock->sk;
 
-       sock_hold(sk);
-       lock_sock(sk);
        if (sk) {
+               sock_hold(sk);
+               lock_sock(sk);
+
                sock_orphan(sk);
                sock->sk = NULL;
                atalk_destroy_socket(sk);
-       }
-       release_sock(sk);
-       sock_put(sk);
 
+               release_sock(sk);
+               sock_put(sk);
+       }
        return 0;
 }