Skip to content

Commit 30e7627

Browse files
Ville TervoGustavo F. Padovan
authored andcommitted
Bluetooth: Use ERR_PTR as return error from hci_connect
Use ERR_PTR mechanism to return error from hci_connect. Signed-off-by: Ville Tervo <ville.tervo@nokia.com> Signed-off-by: Anderson Briglia <anderson.briglia@openbossa.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
1 parent bdce7ba commit 30e7627

4 files changed

Lines changed: 14 additions & 12 deletions

File tree

‎net/bluetooth/hci_conn.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,10 +431,10 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8
431431
if (type == LE_LINK) {
432432
le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst);
433433
if (le)
434-
return NULL;
434+
return ERR_PTR(-EBUSY);
435435
le = hci_conn_add(hdev, LE_LINK, dst);
436436
if (!le)
437-
return NULL;
437+
return ERR_PTR(-ENOMEM);
438438
if (le->state == BT_OPEN)
439439
hci_le_connect(le);
440440

‎net/bluetooth/l2cap_core.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -852,8 +852,6 @@ int l2cap_do_connect(struct sock *sk)
852852

853853
hci_dev_lock_bh(hdev);
854854

855-
err = -ENOMEM;
856-
857855
auth_type = l2cap_get_auth_type(sk);
858856

859857
if (l2cap_pi(sk)->dcid == L2CAP_CID_LE_DATA)
@@ -863,17 +861,18 @@ int l2cap_do_connect(struct sock *sk)
863861
hcon = hci_connect(hdev, ACL_LINK, dst,
864862
l2cap_pi(sk)->sec_level, auth_type);
865863

866-
if (!hcon)
864+
if (IS_ERR(hcon)) {
865+
err = PTR_ERR(hcon);
867866
goto done;
867+
}
868868

869869
conn = l2cap_conn_add(hcon, 0);
870870
if (!conn) {
871871
hci_conn_put(hcon);
872+
err = -ENOMEM;
872873
goto done;
873874
}
874875

875-
err = 0;
876-
877876
/* Update source addr of the socket */
878877
bacpy(src, conn->src);
879878

@@ -892,6 +891,8 @@ int l2cap_do_connect(struct sock *sk)
892891
l2cap_do_start(sk);
893892
}
894893

894+
err = 0;
895+
895896
done:
896897
hci_dev_unlock_bh(hdev);
897898
hci_dev_put(hdev);

‎net/bluetooth/mgmt.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,8 +1171,8 @@ static int pair_device(struct sock *sk, u16 index, unsigned char *data, u16 len)
11711171
}
11721172

11731173
conn = hci_connect(hdev, ACL_LINK, &cp->bdaddr, sec_level, auth_type);
1174-
if (!conn) {
1175-
err = -ENOMEM;
1174+
if (IS_ERR(conn)) {
1175+
err = PTR_ERR(conn);
11761176
goto unlock;
11771177
}
11781178

‎net/bluetooth/sco.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,20 +190,21 @@ static int sco_connect(struct sock *sk)
190190

191191
hci_dev_lock_bh(hdev);
192192

193-
err = -ENOMEM;
194-
195193
if (lmp_esco_capable(hdev) && !disable_esco)
196194
type = ESCO_LINK;
197195
else
198196
type = SCO_LINK;
199197

200198
hcon = hci_connect(hdev, type, dst, BT_SECURITY_LOW, HCI_AT_NO_BONDING);
201-
if (!hcon)
199+
if (IS_ERR(hcon)) {
200+
err = PTR_ERR(hcon);
202201
goto done;
202+
}
203203

204204
conn = sco_conn_add(hcon, 0);
205205
if (!conn) {
206206
hci_conn_put(hcon);
207+
err = -ENOMEM;
207208
goto done;
208209
}
209210

0 commit comments

Comments
 (0)