aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/sco.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/bluetooth/sco.c')
-rw-r--r--net/bluetooth/sco.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index d0927d1fdada..960c6d1637da 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -44,7 +44,7 @@
44#include <net/sock.h> 44#include <net/sock.h>
45 45
46#include <asm/system.h> 46#include <asm/system.h>
47#include <asm/uaccess.h> 47#include <linux/uaccess.h>
48 48
49#include <net/bluetooth/bluetooth.h> 49#include <net/bluetooth/bluetooth.h>
50#include <net/bluetooth/hci_core.h> 50#include <net/bluetooth/hci_core.h>
@@ -52,7 +52,7 @@
52 52
53#define VERSION "0.6" 53#define VERSION "0.6"
54 54
55static int disable_esco = 0; 55static int disable_esco;
56 56
57static const struct proto_ops sco_sock_ops; 57static const struct proto_ops sco_sock_ops;
58 58
@@ -138,16 +138,17 @@ static inline struct sock *sco_chan_get(struct sco_conn *conn)
138 138
139static int sco_conn_del(struct hci_conn *hcon, int err) 139static int sco_conn_del(struct hci_conn *hcon, int err)
140{ 140{
141 struct sco_conn *conn; 141 struct sco_conn *conn = hcon->sco_data;
142 struct sock *sk; 142 struct sock *sk;
143 143
144 if (!(conn = hcon->sco_data)) 144 if (!conn)
145 return 0; 145 return 0;
146 146
147 BT_DBG("hcon %p conn %p, err %d", hcon, conn, err); 147 BT_DBG("hcon %p conn %p, err %d", hcon, conn, err);
148 148
149 /* Kill socket */ 149 /* Kill socket */
150 if ((sk = sco_chan_get(conn))) { 150 sk = sco_chan_get(conn);
151 if (sk) {
151 bh_lock_sock(sk); 152 bh_lock_sock(sk);
152 sco_sock_clear_timer(sk); 153 sco_sock_clear_timer(sk);
153 sco_chan_del(sk, err); 154 sco_chan_del(sk, err);
@@ -185,7 +186,8 @@ static int sco_connect(struct sock *sk)
185 186
186 BT_DBG("%s -> %s", batostr(src), batostr(dst)); 187 BT_DBG("%s -> %s", batostr(src), batostr(dst));
187 188
188 if (!(hdev = hci_get_route(dst, src))) 189 hdev = hci_get_route(dst, src);
190 if (!hdev)
189 return -EHOSTUNREACH; 191 return -EHOSTUNREACH;
190 192
191 hci_dev_lock_bh(hdev); 193 hci_dev_lock_bh(hdev);
@@ -510,7 +512,8 @@ static int sco_sock_connect(struct socket *sock, struct sockaddr *addr, int alen
510 /* Set destination address and psm */ 512 /* Set destination address and psm */
511 bacpy(&bt_sk(sk)->dst, &sa->sco_bdaddr); 513 bacpy(&bt_sk(sk)->dst, &sa->sco_bdaddr);
512 514
513 if ((err = sco_connect(sk))) 515 err = sco_connect(sk);
516 if (err)
514 goto done; 517 goto done;
515 518
516 err = bt_sock_wait_state(sk, BT_CONNECTED, 519 err = bt_sock_wait_state(sk, BT_CONNECTED,
@@ -828,13 +831,14 @@ static void sco_chan_del(struct sock *sk, int err)
828 831
829static void sco_conn_ready(struct sco_conn *conn) 832static void sco_conn_ready(struct sco_conn *conn)
830{ 833{
831 struct sock *parent, *sk; 834 struct sock *parent;
835 struct sock *sk = conn->sk;
832 836
833 BT_DBG("conn %p", conn); 837 BT_DBG("conn %p", conn);
834 838
835 sco_conn_lock(conn); 839 sco_conn_lock(conn);
836 840
837 if ((sk = conn->sk)) { 841 if (sk) {
838 sco_sock_clear_timer(sk); 842 sco_sock_clear_timer(sk);
839 bh_lock_sock(sk); 843 bh_lock_sock(sk);
840 sk->sk_state = BT_CONNECTED; 844 sk->sk_state = BT_CONNECTED;
@@ -882,7 +886,7 @@ static int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 type)
882 int lm = 0; 886 int lm = 0;
883 887
884 if (type != SCO_LINK && type != ESCO_LINK) 888 if (type != SCO_LINK && type != ESCO_LINK)
885 return 0; 889 return -EINVAL;
886 890
887 BT_DBG("hdev %s, bdaddr %s", hdev->name, batostr(bdaddr)); 891 BT_DBG("hdev %s, bdaddr %s", hdev->name, batostr(bdaddr));
888 892
@@ -908,7 +912,7 @@ static int sco_connect_cfm(struct hci_conn *hcon, __u8 status)
908 BT_DBG("hcon %p bdaddr %s status %d", hcon, batostr(&hcon->dst), status); 912 BT_DBG("hcon %p bdaddr %s status %d", hcon, batostr(&hcon->dst), status);
909 913
910 if (hcon->type != SCO_LINK && hcon->type != ESCO_LINK) 914 if (hcon->type != SCO_LINK && hcon->type != ESCO_LINK)
911 return 0; 915 return -EINVAL;
912 916
913 if (!status) { 917 if (!status) {
914 struct sco_conn *conn; 918 struct sco_conn *conn;
@@ -927,7 +931,7 @@ static int sco_disconn_cfm(struct hci_conn *hcon, __u8 reason)
927 BT_DBG("hcon %p reason %d", hcon, reason); 931 BT_DBG("hcon %p reason %d", hcon, reason);
928 932
929 if (hcon->type != SCO_LINK && hcon->type != ESCO_LINK) 933 if (hcon->type != SCO_LINK && hcon->type != ESCO_LINK)
930 return 0; 934 return -EINVAL;
931 935
932 sco_conn_del(hcon, bt_err(reason)); 936 sco_conn_del(hcon, bt_err(reason));
933 937