Skip to contentSkip to conversation

bluetooth:Fix error checking in the function hci_disconn_complete_evt

PATCH In review Nicholas Krause 2 participants 2 messages Aug 19, 2015 – Aug 24, 2015

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bluetooth:Fix error checking in the function hci_disconn_complete_evt

This fixes error checking in the function hci_disconn_complete_evt to properly check if it's call to the function hci_remove_link_key returns NULL to signal it has not correctly removed the link key on the passed hci_dev structure pointer and if so jump to the goto label unlock to unlock the caller's passed hci_dev structure pointer as this function cannot continue its intended work after this failed

---
 net/bluetooth/hci_event.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/bluetooth/hci_event.c +4 -2
index 32363c2..5174649 100644
@@ -2448,8 +2448,10 @@ static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
 				reason, mgmt_connected);
 
 	if (conn->type == ACL_LINK) {
-		if (test_bit(HCI_CONN_FLUSH_KEY, &conn->flags))
-			hci_remove_link_key(hdev, &conn->dst);
+		if (test_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) {
+			if (!hci_remove_link_key(hdev, &conn->dst))
+				goto unlock;
+		}
 
 		hci_update_page_scan(hdev);
 	}
Signature · 1 line
2.1.4
#1 lore raw

Hi Nicholas,

Quoted 19 lines · Nicholas Krause

This fixes error checking in the function hci_disconn_complete_evt to properly check if it's call to the function hci_remove_link_key returns NULL to signal it has not correctly removed the link key on the passed hci_dev structure pointer and if so jump to the goto label unlock to unlock the caller's passed hci_dev structure pointer as this function cannot continue its intended work after this failed

---
 net/bluetooth/hci_event.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/bluetooth/hci_event.c +0 -0
index 32363c2..5174649 100644
@@ -2448,8 +2448,10 @@ static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
 				reason, mgmt_connected);
 

net/bluetooth/hci_event.c static void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) · line 2457

Quoted 10 lines
net/bluetooth/hci_event.c +4 -2
 	if (conn->type == ACL_LINK) {
-		if (test_bit(HCI_CONN_FLUSH_KEY, &conn->flags))
-			hci_remove_link_key(hdev, &conn->dst);
+		if (test_bit(HCI_CONN_FLUSH_KEY, &conn->flags)) {
+			if (!hci_remove_link_key(hdev, &conn->dst))
+				goto unlock;
+		}
 
 		hci_update_page_scan(hdev);
 	}

This doesn't look correct to me. The only scenario where hci_remove_link_key() may fail is if there was no existing key (it'll return -ENOENT then). This is a perfectly normal thing that will occur for a disconnection of a non-paired device, so any other cleanups like hci_update_page_scan() should still go ahead.

Johan