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>
This commit is contained in:
parent
3f1732462c
commit
bb4b2a9ae3
|
@ -1050,7 +1050,7 @@ int mgmt_discovering(struct hci_dev *hdev, u8 discovering);
|
||||||
int mgmt_interleaved_discovery(struct hci_dev *hdev);
|
int mgmt_interleaved_discovery(struct hci_dev *hdev);
|
||||||
int mgmt_device_blocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type);
|
int mgmt_device_blocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type);
|
||||||
int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type);
|
int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type);
|
||||||
|
bool mgmt_valid_hdev(struct hci_dev *hdev);
|
||||||
int mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, u8 persistent);
|
int mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, u8 persistent);
|
||||||
|
|
||||||
/* HCI info for socket */
|
/* HCI info for socket */
|
||||||
|
|
|
@ -696,7 +696,8 @@ int hci_dev_open(__u16 dev)
|
||||||
hci_dev_hold(hdev);
|
hci_dev_hold(hdev);
|
||||||
set_bit(HCI_UP, &hdev->flags);
|
set_bit(HCI_UP, &hdev->flags);
|
||||||
hci_notify(hdev, HCI_DEV_UP);
|
hci_notify(hdev, HCI_DEV_UP);
|
||||||
if (!test_bit(HCI_SETUP, &hdev->dev_flags)) {
|
if (!test_bit(HCI_SETUP, &hdev->dev_flags) &&
|
||||||
|
mgmt_valid_hdev(hdev)) {
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock(hdev);
|
||||||
mgmt_powered(hdev, 1);
|
mgmt_powered(hdev, 1);
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock(hdev);
|
||||||
|
@ -797,7 +798,8 @@ static int hci_dev_do_close(struct hci_dev *hdev)
|
||||||
* and no tasks are scheduled. */
|
* and no tasks are scheduled. */
|
||||||
hdev->close(hdev);
|
hdev->close(hdev);
|
||||||
|
|
||||||
if (!test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags)) {
|
if (!test_and_clear_bit(HCI_AUTO_OFF, &hdev->dev_flags) &&
|
||||||
|
mgmt_valid_hdev(hdev)) {
|
||||||
hci_dev_lock(hdev);
|
hci_dev_lock(hdev);
|
||||||
mgmt_powered(hdev, 0);
|
mgmt_powered(hdev, 0);
|
||||||
hci_dev_unlock(hdev);
|
hci_dev_unlock(hdev);
|
||||||
|
|
|
@ -193,6 +193,11 @@ static u8 mgmt_status_table[] = {
|
||||||
MGMT_STATUS_CONNECT_FAILED, /* MAC Connection Failed */
|
MGMT_STATUS_CONNECT_FAILED, /* MAC Connection Failed */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool mgmt_valid_hdev(struct hci_dev *hdev)
|
||||||
|
{
|
||||||
|
return hdev->dev_type == HCI_BREDR;
|
||||||
|
}
|
||||||
|
|
||||||
static u8 mgmt_status(u8 hci_status)
|
static u8 mgmt_status(u8 hci_status)
|
||||||
{
|
{
|
||||||
if (hci_status < ARRAY_SIZE(mgmt_status_table))
|
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,
|
||||||
u16 data_len)
|
u16 data_len)
|
||||||
{
|
{
|
||||||
struct mgmt_rp_read_index_list *rp;
|
struct mgmt_rp_read_index_list *rp;
|
||||||
struct list_head *p;
|
|
||||||
struct hci_dev *d;
|
struct hci_dev *d;
|
||||||
size_t rp_len;
|
size_t rp_len;
|
||||||
u16 count;
|
u16 count;
|
||||||
|
@ -328,7 +332,10 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data,
|
||||||
read_lock(&hci_dev_list_lock);
|
read_lock(&hci_dev_list_lock);
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
list_for_each(p, &hci_dev_list) {
|
list_for_each_entry(d, &hci_dev_list, list) {
|
||||||
|
if (!mgmt_valid_hdev(d))
|
||||||
|
continue;
|
||||||
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,6 +353,9 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data,
|
||||||
if (test_bit(HCI_SETUP, &d->dev_flags))
|
if (test_bit(HCI_SETUP, &d->dev_flags))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (!mgmt_valid_hdev(d))
|
||||||
|
continue;
|
||||||
|
|
||||||
rp->index[i++] = cpu_to_le16(d->id);
|
rp->index[i++] = cpu_to_le16(d->id);
|
||||||
BT_DBG("Added hci%u", d->id);
|
BT_DBG("Added hci%u", d->id);
|
||||||
}
|
}
|
||||||
|
@ -2820,6 +2830,9 @@ static void cmd_status_rsp(struct pending_cmd *cmd, void *data)
|
||||||
|
|
||||||
int mgmt_index_added(struct hci_dev *hdev)
|
int mgmt_index_added(struct hci_dev *hdev)
|
||||||
{
|
{
|
||||||
|
if (!mgmt_valid_hdev(hdev))
|
||||||
|
return -ENOTSUPP;
|
||||||
|
|
||||||
return mgmt_event(MGMT_EV_INDEX_ADDED, hdev, NULL, 0, NULL);
|
return mgmt_event(MGMT_EV_INDEX_ADDED, hdev, NULL, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2827,6 +2840,9 @@ int mgmt_index_removed(struct hci_dev *hdev)
|
||||||
{
|
{
|
||||||
u8 status = MGMT_STATUS_INVALID_INDEX;
|
u8 status = MGMT_STATUS_INVALID_INDEX;
|
||||||
|
|
||||||
|
if (!mgmt_valid_hdev(hdev))
|
||||||
|
return -ENOTSUPP;
|
||||||
|
|
||||||
mgmt_pending_foreach(0, hdev, cmd_status_rsp, &status);
|
mgmt_pending_foreach(0, hdev, cmd_status_rsp, &status);
|
||||||
|
|
||||||
return mgmt_event(MGMT_EV_INDEX_REMOVED, hdev, NULL, 0, NULL);
|
return mgmt_event(MGMT_EV_INDEX_REMOVED, hdev, NULL, 0, NULL);
|
||||||
|
|
Loading…
Reference in New Issue