Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0ef2c42f authored by Marcel Holtmann's avatar Marcel Holtmann
Browse files

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: default avatarMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
parent 9e8305b3
Loading
Loading
Loading
Loading
+16 −2
Original line number Original line Diff line number Diff line
@@ -483,6 +483,10 @@ static struct sk_buff *create_monitor_ctrl_open(struct sock *sk)
	u8 ver[3];
	u8 ver[3];
	u32 flags;
	u32 flags;


	/* No message needed when cookie is not present */
	if (!hci_pi(sk)->cookie)
		return NULL;

	skb = bt_skb_alloc(14 + TASK_COMM_LEN , GFP_ATOMIC);
	skb = bt_skb_alloc(14 + TASK_COMM_LEN , GFP_ATOMIC);
	if (!skb)
	if (!skb)
		return NULL;
		return NULL;
@@ -501,6 +505,9 @@ static struct sk_buff *create_monitor_ctrl_open(struct sock *sk)


	hdr = (void *)skb_push(skb, HCI_MON_HDR_SIZE);
	hdr = (void *)skb_push(skb, HCI_MON_HDR_SIZE);
	hdr->opcode = cpu_to_le16(HCI_MON_CTRL_OPEN);
	hdr->opcode = cpu_to_le16(HCI_MON_CTRL_OPEN);
	if (hci_pi(sk)->hdev)
		hdr->index = cpu_to_le16(hci_pi(sk)->hdev->id);
	else
		hdr->index = cpu_to_le16(HCI_DEV_NONE);
		hdr->index = cpu_to_le16(HCI_DEV_NONE);
	hdr->len = cpu_to_le16(skb->len - HCI_MON_HDR_SIZE);
	hdr->len = cpu_to_le16(skb->len - HCI_MON_HDR_SIZE);


@@ -512,6 +519,10 @@ static struct sk_buff *create_monitor_ctrl_close(struct sock *sk)
	struct hci_mon_hdr *hdr;
	struct hci_mon_hdr *hdr;
	struct sk_buff *skb;
	struct sk_buff *skb;


	/* No message needed when cookie is not present */
	if (!hci_pi(sk)->cookie)
		return NULL;

	skb = bt_skb_alloc(4, GFP_ATOMIC);
	skb = bt_skb_alloc(4, GFP_ATOMIC);
	if (!skb)
	if (!skb)
		return NULL;
		return NULL;
@@ -522,6 +533,9 @@ static struct sk_buff *create_monitor_ctrl_close(struct sock *sk)


	hdr = (void *)skb_push(skb, HCI_MON_HDR_SIZE);
	hdr = (void *)skb_push(skb, HCI_MON_HDR_SIZE);
	hdr->opcode = cpu_to_le16(HCI_MON_CTRL_CLOSE);
	hdr->opcode = cpu_to_le16(HCI_MON_CTRL_CLOSE);
	if (hci_pi(sk)->hdev)
		hdr->index = cpu_to_le16(hci_pi(sk)->hdev->id);
	else
		hdr->index = cpu_to_le16(HCI_DEV_NONE);
		hdr->index = cpu_to_le16(HCI_DEV_NONE);
	hdr->len = cpu_to_le16(skb->len - HCI_MON_HDR_SIZE);
	hdr->len = cpu_to_le16(skb->len - HCI_MON_HDR_SIZE);