diff options
author | Andrei Emeltchenko <andrei.emeltchenko@intel.com> | 2012-07-19 10:03:40 -0400 |
---|---|---|
committer | Gustavo Padovan <gustavo.padovan@collabora.co.uk> | 2012-08-06 14:02:54 -0400 |
commit | bb4b2a9ae38ef3bac69627f35e4f916752631fd1 (patch) | |
tree | 451a3577621b6169767a5f3605b9cf536e0a804f /net | |
parent | 3f1732462c0e45ac9b0c09035751d7b2c1b89cc0 (diff) |
Bluetooth: mgmt: Managing only BR/EDR HCI controllers
Add check that HCI controller is BR/EDR. AMP controller shall not be
managed by mgmt interface and consequently user space.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Diffstat (limited to 'net')
-rw-r--r-- | net/bluetooth/hci_core.c | 6 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 20 |
2 files changed, 22 insertions, 4 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index d4de5db18d5a..fa974a19d365 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -696,7 +696,8 @@ int hci_dev_open(__u16 dev) | |||
696 | hci_dev_hold(hdev); | 696 | hci_dev_hold(hdev); |
697 | set_bit(HCI_UP, &hdev->flags); | 697 | set_bit(HCI_UP, &hdev->flags); |
698 | hci_notify(hdev, HCI_DEV_UP); | 698 | hci_notify(hdev, HCI_DEV_UP); |
699 | if (!test_bit(HCI_SETUP, &hdev->dev_flags)) { | 699 | if (!test_bit(HCI_SETUP, &hdev->dev_flags) && |
700 | mgmt_valid_hdev(hdev)) { | ||
700 | hci_dev_lock(hdev); | 701 | hci_dev_lock(hdev); |
701 | mgmt_powered(hdev, 1); | 702 | mgmt_powered(hdev, 1); |
702 | hci_dev_unlock(hdev); | 703 | hci_dev_unlock(hdev); |
@@ -797,7 +798,8 @@ static int hci_dev_do_close(struct hci_dev *hdev) | |||
797 | * and no tasks are scheduled. */ | 798 | * and no tasks are scheduled. */ |
798 | hdev->close(hdev); | 799 | hdev->close(hdev); |
799 | 800 | ||
800 | if (!test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags)) { | 801 | if (!test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags) && |
802 | mgmt_valid_hdev(hdev)) { | ||
801 | hci_dev_lock(hdev); | 803 | hci_dev_lock(hdev); |
802 | mgmt_powered(hdev, 0); | 804 | mgmt_powered(hdev, 0); |
803 | hci_dev_unlock(hdev); | 805 | hci_dev_unlock(hdev); |
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index ad6613d17ca6..2a0f695e33d4 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -193,6 +193,11 @@ static u8 mgmt_status_table[] = { | |||
193 | MGMT_STATUS_CONNECT_FAILED, /* MAC Connection Failed */ | 193 | MGMT_STATUS_CONNECT_FAILED, /* MAC Connection Failed */ |
194 | }; | 194 | }; |
195 | 195 | ||
196 | bool mgmt_valid_hdev(struct hci_dev *hdev) | ||
197 | { | ||
198 | return hdev->dev_type == HCI_BREDR; | ||
199 | } | ||
200 | |||
196 | static u8 mgmt_status(u8 hci_status) | 201 | static u8 mgmt_status(u8 hci_status) |
197 | { | 202 | { |
198 | if (hci_status < ARRAY_SIZE(mgmt_status_table)) | 203 | if (hci_status < ARRAY_SIZE(mgmt_status_table)) |
@@ -317,7 +322,6 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data, | |||
317 | u16 data_len) | 322 | u16 data_len) |
318 | { | 323 | { |
319 | struct mgmt_rp_read_index_list *rp; | 324 | struct mgmt_rp_read_index_list *rp; |
320 | struct list_head *p; | ||
321 | struct hci_dev *d; | 325 | struct hci_dev *d; |
322 | size_t rp_len; | 326 | size_t rp_len; |
323 | u16 count; | 327 | u16 count; |
@@ -328,7 +332,10 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data, | |||
328 | read_lock(&hci_dev_list_lock); | 332 | read_lock(&hci_dev_list_lock); |
329 | 333 | ||
330 | count = 0; | 334 | count = 0; |
331 | list_for_each(p, &hci_dev_list) { | 335 | list_for_each_entry(d, &hci_dev_list, list) { |
336 | if (!mgmt_valid_hdev(d)) | ||
337 | continue; | ||
338 | |||
332 | count++; | 339 | count++; |
333 | } | 340 | } |
334 | 341 | ||
@@ -346,6 +353,9 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data, | |||
346 | if (test_bit(HCI_SETUP, &d->dev_flags)) | 353 | if (test_bit(HCI_SETUP, &d->dev_flags)) |
347 | continue; | 354 | continue; |
348 | 355 | ||
356 | if (!mgmt_valid_hdev(d)) | ||
357 | continue; | ||
358 | |||
349 | rp->index[i++] = cpu_to_le16(d->id); | 359 | rp->index[i++] = cpu_to_le16(d->id); |
350 | BT_DBG("Added hci%u", d->id); | 360 | BT_DBG("Added hci%u", d->id); |
351 | } | 361 | } |
@@ -2820,6 +2830,9 @@ static void cmd_status_rsp(struct pending_cmd *cmd, void *data) | |||
2820 | 2830 | ||
2821 | int mgmt_index_added(struct hci_dev *hdev) | 2831 | int mgmt_index_added(struct hci_dev *hdev) |
2822 | { | 2832 | { |
2833 | if (!mgmt_valid_hdev(hdev)) | ||
2834 | return -ENOTSUPP; | ||
2835 | |||
2823 | return mgmt_event(MGMT_EV_INDEX_ADDED, hdev, NULL, 0, NULL); | 2836 | return mgmt_event(MGMT_EV_INDEX_ADDED, hdev, NULL, 0, NULL); |
2824 | } | 2837 | } |
2825 | 2838 | ||
@@ -2827,6 +2840,9 @@ int mgmt_index_removed(struct hci_dev *hdev) | |||
2827 | { | 2840 | { |
2828 | u8 status = MGMT_STATUS_INVALID_INDEX; | 2841 | u8 status = MGMT_STATUS_INVALID_INDEX; |
2829 | 2842 | ||
2843 | if (!mgmt_valid_hdev(hdev)) | ||
2844 | return -ENOTSUPP; | ||
2845 | |||
2830 | mgmt_pending_foreach(0, hdev, cmd_status_rsp, &status); | 2846 | mgmt_pending_foreach(0, hdev, cmd_status_rsp, &status); |
2831 | 2847 | ||
2832 | return mgmt_event(MGMT_EV_INDEX_REMOVED, hdev, NULL, 0, NULL); | 2848 | return mgmt_event(MGMT_EV_INDEX_REMOVED, hdev, NULL, 0, NULL); |