Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 290987
b: refs/heads/master
c: 7cc2ade
h: refs/heads/master
i:
  290985: 5b293f5
  290983: 4c9a9bf
v: v3
  • Loading branch information
Marcel Holtmann authored and Johan Hedberg committed Feb 20, 2012
1 parent a99e981 commit c3ec719
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 17 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3a208627f3ac83d3b749608770f7eb631db31a77
refs/heads/master: 7cc2ade2cbc6f71090f0f8d0e11cb68886ddc65e
47 changes: 31 additions & 16 deletions trunk/net/bluetooth/hci_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,34 +367,49 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_le
if (haddr.hci_family != AF_BLUETOOTH)
return -EINVAL;

if (haddr.hci_channel > HCI_CHANNEL_CONTROL)
return -EINVAL;

if (haddr.hci_channel == HCI_CHANNEL_CONTROL) {
if (!enable_mgmt)
return -EINVAL;
set_bit(HCI_PI_MGMT_INIT, &hci_pi(sk)->flags);
}

lock_sock(sk);

if (sk->sk_state == BT_BOUND || hci_pi(sk)->hdev) {
if (sk->sk_state == BT_BOUND) {
err = -EALREADY;
goto done;
}

if (haddr.hci_dev != HCI_DEV_NONE) {
hdev = hci_dev_get(haddr.hci_dev);
if (!hdev) {
err = -ENODEV;
switch (haddr.hci_channel) {
case HCI_CHANNEL_RAW:
if (hci_pi(sk)->hdev) {
err = -EALREADY;
goto done;
}

atomic_inc(&hdev->promisc);
if (haddr.hci_dev != HCI_DEV_NONE) {
hdev = hci_dev_get(haddr.hci_dev);
if (!hdev) {
err = -ENODEV;
goto done;
}

atomic_inc(&hdev->promisc);
}

hci_pi(sk)->hdev = hdev;
break;

case HCI_CHANNEL_CONTROL:
if (haddr.hci_dev != HCI_DEV_NONE || !enable_mgmt) {
err = -EINVAL;
goto done;
}

set_bit(HCI_PI_MGMT_INIT, &hci_pi(sk)->flags);
break;

default:
err = -EINVAL;
goto done;
}


hci_pi(sk)->channel = haddr.hci_channel;
hci_pi(sk)->hdev = hdev;
sk->sk_state = BT_BOUND;

done:
Expand Down

0 comments on commit c3ec719

Please sign in to comment.