Commit c100c8f4c3c6f2a407bdbaaad2c4f1062e6a473a

Authored by David S. Miller
1 parent c379474591

appletalk: Fix OOPS in atalk_release().

Commit 60d9f461a20ba59219fdcdc30cbf8e3a4ad3f625 ("appletalk: remove
the BKL") added a dereference of "sk" before checking for NULL in
atalk_release().

Guard the code block completely, rather than partially, with the
NULL check.

Reported-by: Dave Jones <davej@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 1 changed file with 6 additions and 5 deletions Side-by-side Diff

... ... @@ -1051,16 +1051,17 @@
1051 1051 {
1052 1052 struct sock *sk = sock->sk;
1053 1053  
1054   - sock_hold(sk);
1055   - lock_sock(sk);
1056 1054 if (sk) {
  1055 + sock_hold(sk);
  1056 + lock_sock(sk);
  1057 +
1057 1058 sock_orphan(sk);
1058 1059 sock->sk = NULL;
1059 1060 atalk_destroy_socket(sk);
1060   - }
1061   - release_sock(sk);
1062   - sock_put(sk);
1063 1061  
  1062 + release_sock(sk);
  1063 + sock_put(sk);
  1064 + }
1064 1065 return 0;
1065 1066 }
1066 1067