diff options
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/l2cap_core.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 8d53fc57faba..b6f9777e057d 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -6980,8 +6980,6 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, | |||
6980 | 6980 | ||
6981 | hci_dev_lock(hdev); | 6981 | hci_dev_lock(hdev); |
6982 | 6982 | ||
6983 | l2cap_chan_lock(chan); | ||
6984 | |||
6985 | if (!is_valid_psm(__le16_to_cpu(psm), dst_type) && !cid && | 6983 | if (!is_valid_psm(__le16_to_cpu(psm), dst_type) && !cid && |
6986 | chan->chan_type != L2CAP_CHAN_RAW) { | 6984 | chan->chan_type != L2CAP_CHAN_RAW) { |
6987 | err = -EINVAL; | 6985 | err = -EINVAL; |
@@ -7078,17 +7076,20 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, | |||
7078 | goto done; | 7076 | goto done; |
7079 | } | 7077 | } |
7080 | 7078 | ||
7079 | mutex_lock(&conn->chan_lock); | ||
7080 | l2cap_chan_lock(chan); | ||
7081 | |||
7081 | if (cid && __l2cap_get_chan_by_dcid(conn, cid)) { | 7082 | if (cid && __l2cap_get_chan_by_dcid(conn, cid)) { |
7082 | hci_conn_drop(hcon); | 7083 | hci_conn_drop(hcon); |
7083 | err = -EBUSY; | 7084 | err = -EBUSY; |
7084 | goto done; | 7085 | goto chan_unlock; |
7085 | } | 7086 | } |
7086 | 7087 | ||
7087 | /* Update source addr of the socket */ | 7088 | /* Update source addr of the socket */ |
7088 | bacpy(&chan->src, &hcon->src); | 7089 | bacpy(&chan->src, &hcon->src); |
7089 | chan->src_type = bdaddr_type(hcon, hcon->src_type); | 7090 | chan->src_type = bdaddr_type(hcon, hcon->src_type); |
7090 | 7091 | ||
7091 | l2cap_chan_add(conn, chan); | 7092 | __l2cap_chan_add(conn, chan); |
7092 | 7093 | ||
7093 | /* l2cap_chan_add takes its own ref so we can drop this one */ | 7094 | /* l2cap_chan_add takes its own ref so we can drop this one */ |
7094 | hci_conn_drop(hcon); | 7095 | hci_conn_drop(hcon); |
@@ -7114,8 +7115,10 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, | |||
7114 | 7115 | ||
7115 | err = 0; | 7116 | err = 0; |
7116 | 7117 | ||
7117 | done: | 7118 | chan_unlock: |
7118 | l2cap_chan_unlock(chan); | 7119 | l2cap_chan_unlock(chan); |
7120 | mutex_unlock(&conn->chan_lock); | ||
7121 | done: | ||
7119 | hci_dev_unlock(hdev); | 7122 | hci_dev_unlock(hdev); |
7120 | hci_dev_put(hdev); | 7123 | hci_dev_put(hdev); |
7121 | return err; | 7124 | return err; |