Skip to content

Commit a6ad2a6

Browse files
jhedbergholtmann
authored andcommitted
Bluetooth: Fix removing connection parameters when unpairing
The commit 89cbb06 introduced support for deferred connection parameter removal when unpairing by removing them only once an existing connection gets disconnected. However, it failed to address the scenario when we're *not* connected and do an unpair operation. What makes things worse is that most user space BlueZ versions will first issue a disconnect request and only then unpair, meaning the buggy code will be triggered every time. This effectively causes the kernel to resume scanning and reconnect to a device for which we've removed all keys and GATT database information. This patch fixes the issue by adding the missing call to the hci_conn_params_del() function to a branch which handles the case of no existing connection. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Cc: stable@vger.kernel.org # 3.19+
1 parent 22f8e9d commit a6ad2a6

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎net/bluetooth/mgmt.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3090,6 +3090,11 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data,
30903090
} else {
30913091
u8 addr_type;
30923092

3093+
if (cp->addr.type == BDADDR_LE_PUBLIC)
3094+
addr_type = ADDR_LE_DEV_PUBLIC;
3095+
else
3096+
addr_type = ADDR_LE_DEV_RANDOM;
3097+
30933098
conn = hci_conn_hash_lookup_ba(hdev, LE_LINK,
30943099
&cp->addr.bdaddr);
30953100
if (conn) {
@@ -3105,13 +3110,10 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data,
31053110
*/
31063111
if (!cp->disconnect)
31073112
conn = NULL;
3113+
} else {
3114+
hci_conn_params_del(hdev, &cp->addr.bdaddr, addr_type);
31083115
}
31093116

3110-
if (cp->addr.type == BDADDR_LE_PUBLIC)
3111-
addr_type = ADDR_LE_DEV_PUBLIC;
3112-
else
3113-
addr_type = ADDR_LE_DEV_RANDOM;
3114-
31153117
hci_remove_irk(hdev, &cp->addr.bdaddr, addr_type);
31163118

31173119
err = hci_remove_ltk(hdev, &cp->addr.bdaddr, addr_type);

0 commit comments

Comments
 (0)