diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c index 256f3e97d1f3..5e8146fcb583 100644 --- a/net/x25/af_x25.c +++ b/net/x25/af_x25.c @@ -819,7 +819,7 @@ static int x25_connect(struct socket *sock, struct sockaddr *uaddr, sock->state = SS_CONNECTED; rc = 0; out_put_neigh: - if (rc) { + if (rc && x25->neighbour) { read_lock_bh(&x25_list_lock); x25_neigh_put(x25->neighbour); x25->neighbour = NULL;