Skip to content

Commit

Permalink
Bluetooth: Add paranoid check for existing LE and BR/EDR SMP channels
Browse files Browse the repository at this point in the history
When the SMP channels have been already registered, then print out a
clear WARN_ON message that something went wrong. Also unregister the
existing channels in this case before trying to register new ones.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
  • Loading branch information
Marcel Holtmann authored and Johan Hedberg committed Jan 15, 2015
1 parent 327a719 commit 2b8df32
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions net/bluetooth/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3072,6 +3072,12 @@ int smp_register(struct hci_dev *hdev)
if (!lmp_le_capable(hdev))
return 0;

if (WARN_ON(hdev->smp_data)) {
chan = hdev->smp_data;
hdev->smp_data = NULL;
smp_del_chan(chan);
}

chan = smp_add_cid(hdev, L2CAP_CID_SMP);
if (IS_ERR(chan))
return PTR_ERR(chan);
Expand All @@ -3091,6 +3097,12 @@ int smp_register(struct hci_dev *hdev)
return 0;
}

if (WARN_ON(hdev->smp_bredr_data)) {
chan = hdev->smp_bredr_data;
hdev->smp_bredr_data = NULL;
smp_del_chan(chan);
}

chan = smp_add_cid(hdev, L2CAP_CID_SMP_BREDR);
if (IS_ERR(chan)) {
int err = PTR_ERR(chan);
Expand Down

0 comments on commit 2b8df32

Please sign in to comment.