Bluetooth: Avoid calling device_add() on duplicated HCI conn event
The BCM20702A1 device in the ThinkPad x230 seems to send the HCI Connection Complete event twice for the same connection, for which the stack seems to recover, except for the core device_add() function which is not meant to be called twice for the same device. So let's just avoid calling it in that case. BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=204633Signed-off-by:Olivier Crête <olivier.crete@collabora.com>
-
Can't you just use conn->state being already BT_CONNECTED|BT_CONFIG, instead of poisoning the handler?
old_state = conn->state; ... if (old_state != BT_CONNECTED && old_state != BT_CONFIG) { hci_conn_add_sysfs() }
seems simpler.
-
The fix make sense and looks good. Not sure if gitlab is playing stupid, but the signoff line is mangled with the bugzilla line.
Remember to cc kernel@collabora.com since you are signing-off with your work email.
-
Maintainer
From what I can see from the attached log from the kernel, it seems that the controller decides to send a connection request event again with the same connection handle (which resets the ->state member BT_CONNECT), then it sends a new connection complete (which is where this code is called). Obviously, now that I try to make a log with btmon with more info, I can't reproduce the problem (with either kernel).