diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index c736186aba26..1d603d20970f 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c @@ -300,7 +300,8 @@ static int sco_connect(struct sock *sk) unlock: hci_dev_unlock(hdev); - hci_dev_put(hdev); + if (err) + hci_dev_put(hdev); return err; } @@ -438,12 +439,13 @@ static void __sco_sock_close(struct sock *sk) case BT_CONNECTED: case BT_CONFIG: if (sco_pi(sk)->conn->hcon) { + struct hci_conn *hcon = sco_pi(sk)->conn->hcon; sk->sk_state = BT_DISCONN; sco_sock_set_timer(sk, SCO_DISCONN_TIMEOUT); sco_conn_lock(sco_pi(sk)->conn); - hci_conn_drop(sco_pi(sk)->conn->hcon); sco_pi(sk)->conn->hcon = NULL; sco_conn_unlock(sco_pi(sk)->conn); + hci_conn_put(hcon); } else sco_chan_del(sk, ECONNRESET); break;