Skip to content

Commit a48ab88

Browse files
committed
Merge tag 'for-net-2022-05-11' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth
Luiz Augusto von Dentz says: ==================== bluetooth pull request for net: - Fix the creation of hdev->name when index is greater than 9999 * tag 'for-net-2022-05-11' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth: Bluetooth: Fix the creation of hdev->name ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 8bf6008 + 103a2f3 commit a48ab88

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

include/net/bluetooth/hci_core.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
/* HCI priority */
3737
#define HCI_PRIO_MAX 7
3838

39+
/* HCI maximum id value */
40+
#define HCI_MAX_ID 10000
41+
3942
/* HCI Core structures */
4043
struct inquiry_data {
4144
bdaddr_t bdaddr;

net/bluetooth/hci_core.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2555,10 +2555,10 @@ int hci_register_dev(struct hci_dev *hdev)
25552555
*/
25562556
switch (hdev->dev_type) {
25572557
case HCI_PRIMARY:
2558-
id = ida_simple_get(&hci_index_ida, 0, 0, GFP_KERNEL);
2558+
id = ida_simple_get(&hci_index_ida, 0, HCI_MAX_ID, GFP_KERNEL);
25592559
break;
25602560
case HCI_AMP:
2561-
id = ida_simple_get(&hci_index_ida, 1, 0, GFP_KERNEL);
2561+
id = ida_simple_get(&hci_index_ida, 1, HCI_MAX_ID, GFP_KERNEL);
25622562
break;
25632563
default:
25642564
return -EINVAL;
@@ -2567,7 +2567,7 @@ int hci_register_dev(struct hci_dev *hdev)
25672567
if (id < 0)
25682568
return id;
25692569

2570-
sprintf(hdev->name, "hci%d", id);
2570+
snprintf(hdev->name, sizeof(hdev->name), "hci%d", id);
25712571
hdev->id = id;
25722572

25732573
BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus);

0 commit comments

Comments
 (0)