diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index 5e4f718073b7..b3529051d886 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -477,6 +477,7 @@ static struct sk_buff *create_monitor_event(struct hci_dev *hdev, int event) struct hci_mon_index_info *ii; struct sk_buff *skb; __le16 opcode; + size_t sn, hn; switch (event) { case HCI_DEV_REG: @@ -488,7 +489,10 @@ static struct sk_buff *create_monitor_event(struct hci_dev *hdev, int event) ni->type = hdev->dev_type; ni->bus = hdev->bus; bacpy(&ni->bdaddr, &hdev->bdaddr); - memcpy(ni->name, hdev->name, 8); + sn = sizeof(ni->name); + hn = sizeof(hdev->name); + sn = sn > hn ? hn : sn; + memcpy(ni->name, hdev->name, sn); opcode = cpu_to_le16(HCI_MON_NEW_INDEX); break;