aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2016-08-29 23:00:36 -0400
committerMarcel Holtmann <marcel@holtmann.org>2016-09-19 14:19:34 -0400
commit0ef2c42f8c4e372bad16f67dc0f4b15b9be910f6 (patch)
tree5d84f4caa2e422ac0b1e1fcf880d5a76773da2e0 /net/bluetooth
parent9e8305b39bfa23a83b932007654097f4676c2ba2 (diff)
Bluetooth: Send control open and close only when cookie is present
Only when the cookie has been assigned, then send the open and close monitor messages. Also if the socket is bound to a device, then include the index into the message. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/hci_sock.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index a4227c777d16..0deca758fd9e 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -483,6 +483,10 @@ static struct sk_buff *create_monitor_ctrl_open(struct sock *sk)
483 u8 ver[3]; 483 u8 ver[3];
484 u32 flags; 484 u32 flags;
485 485
486 /* No message needed when cookie is not present */
487 if (!hci_pi(sk)->cookie)
488 return NULL;
489
486 skb = bt_skb_alloc(14 + TASK_COMM_LEN , GFP_ATOMIC); 490 skb = bt_skb_alloc(14 + TASK_COMM_LEN , GFP_ATOMIC);
487 if (!skb) 491 if (!skb)
488 return NULL; 492 return NULL;
@@ -501,7 +505,10 @@ static struct sk_buff *create_monitor_ctrl_open(struct sock *sk)
501 505
502 hdr = (void *)skb_push(skb, HCI_MON_HDR_SIZE); 506 hdr = (void *)skb_push(skb, HCI_MON_HDR_SIZE);
503 hdr->opcode = cpu_to_le16(HCI_MON_CTRL_OPEN); 507 hdr->opcode = cpu_to_le16(HCI_MON_CTRL_OPEN);
504 hdr->index = cpu_to_le16(HCI_DEV_NONE); 508 if (hci_pi(sk)->hdev)
509 hdr->index = cpu_to_le16(hci_pi(sk)->hdev->id);
510 else
511 hdr->index = cpu_to_le16(HCI_DEV_NONE);
505 hdr->len = cpu_to_le16(skb->len - HCI_MON_HDR_SIZE); 512 hdr->len = cpu_to_le16(skb->len - HCI_MON_HDR_SIZE);
506 513
507 return skb; 514 return skb;
@@ -512,6 +519,10 @@ static struct sk_buff *create_monitor_ctrl_close(struct sock *sk)
512 struct hci_mon_hdr *hdr; 519 struct hci_mon_hdr *hdr;
513 struct sk_buff *skb; 520 struct sk_buff *skb;
514 521
522 /* No message needed when cookie is not present */
523 if (!hci_pi(sk)->cookie)
524 return NULL;
525
515 skb = bt_skb_alloc(4, GFP_ATOMIC); 526 skb = bt_skb_alloc(4, GFP_ATOMIC);
516 if (!skb) 527 if (!skb)
517 return NULL; 528 return NULL;
@@ -522,7 +533,10 @@ static struct sk_buff *create_monitor_ctrl_close(struct sock *sk)
522 533
523 hdr = (void *)skb_push(skb, HCI_MON_HDR_SIZE); 534 hdr = (void *)skb_push(skb, HCI_MON_HDR_SIZE);
524 hdr->opcode = cpu_to_le16(HCI_MON_CTRL_CLOSE); 535 hdr->opcode = cpu_to_le16(HCI_MON_CTRL_CLOSE);
525 hdr->index = cpu_to_le16(HCI_DEV_NONE); 536 if (hci_pi(sk)->hdev)
537 hdr->index = cpu_to_le16(hci_pi(sk)->hdev->id);
538 else
539 hdr->index = cpu_to_le16(HCI_DEV_NONE);
526 hdr->len = cpu_to_le16(skb->len - HCI_MON_HDR_SIZE); 540 hdr->len = cpu_to_le16(skb->len - HCI_MON_HDR_SIZE);
527 541
528 return skb; 542 return skb;