linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: Fix registering HCI devices with duplicate name
@ 2012-04-11 15:32 Marcel Holtmann
  2012-04-12  7:38 ` Andrei Emeltchenko
  2012-04-12 11:39 ` Andrei Emeltchenko
  0 siblings, 2 replies; 9+ messages in thread
From: Marcel Holtmann @ 2012-04-11 15:32 UTC (permalink / raw)
  To: linux-bluetooth

When adding HCI devices hci_register_dev assigns the same name
hci1 for subsequently added AMP devices.

...
[ 6958.381886] sysfs: cannot create duplicate filename
        '/devices/virtual/bluetooth/hci1
...

Reported-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
 net/bluetooth/hci_core.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 52c7abf..4becd28 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1741,7 +1741,7 @@ int hci_le_scan(struct hci_dev *hdev, u8 type, u16 interval, u16 window,
 int hci_register_dev(struct hci_dev *hdev)
 {
 	struct list_head *head = &hci_dev_list, *p;
-	int i, id, error;
+	int i, error, min_id, id = 0;
 
 	BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus);
 
@@ -1751,13 +1751,14 @@ int hci_register_dev(struct hci_dev *hdev)
 	/* Do not allow HCI_AMP devices to register at index 0,
 	 * so the index can be used as the AMP controller ID.
 	 */
-	id = (hdev->dev_type == HCI_BREDR) ? 0 : 1;
+	min_id = (hdev->dev_type == HCI_BREDR) ? 0 : 1;
 
 	write_lock(&hci_dev_list_lock);
 
 	/* Find first available device id */
 	list_for_each(p, &hci_dev_list) {
-		if (list_entry(p, struct hci_dev, list)->id != id)
+		if (min_id >= id &&
+		    list_entry(p, struct hci_dev, list)->id != id)
 			break;
 		head = p; id++;
 	}
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-04-13  8:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-11 15:32 [PATCH] Bluetooth: Fix registering HCI devices with duplicate name Marcel Holtmann
2012-04-12  7:38 ` Andrei Emeltchenko
2012-04-12  9:50   ` Marcel Holtmann
2012-04-12 10:03     ` Andrei Emeltchenko
2012-04-12 10:15       ` Marcel Holtmann
2012-04-12 10:45         ` Andrei Emeltchenko
2012-04-12 10:50           ` Marcel Holtmann
2012-04-12 11:39 ` Andrei Emeltchenko
2012-04-13  8:29   ` Andrei Emeltchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).