Skip to contentSkip to conversation

Bluetooth: Add paranoid check for existing LE and BR/EDR SMP channels

PATCH Applied Marcel Holtmann 2 participants 2 messages Jan 15, 2015

Subsystems (2)
lore
Share & tools
lore

Marcel Holtmann

author maintainer
#0 lore raw

PATCH v2 1/1 Bluetooth: Add paranoid check for existing LE and BR/EDR SMP channels

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.

---
 net/bluetooth/smp.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
net/bluetooth/smp.c +12 -0
index 08a9314f3ca7..37d9180bfe1c 100644
@@ -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);
@@ -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);
Signature · 1 line
2.1.0
#1 lore raw

Hi Marcel,

Quoted 8 lines · Marcel Holtmann

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.

---
 net/bluetooth/smp.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Applied to bluetooth-next. Thanks.

Johan