Skip to content

Commit b6f9804

Browse files
Waldemar RymarkiewiczGustavo F. Padovan
authored andcommitted
Bluetooth: Fix possible NULL pointer dereference
Checking conn->pending_sec_level if there is no connection leads to potential null pointer dereference. Don't process pin_code_request_event at all if no connection exists. Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@gmail.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
1 parent 67c9e84 commit b6f9804

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎net/bluetooth/hci_event.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2174,7 +2174,10 @@ static inline void hci_pin_code_request_evt(struct hci_dev *hdev, struct sk_buff
21742174
hci_dev_lock(hdev);
21752175

21762176
conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
2177-
if (conn && conn->state == BT_CONNECTED) {
2177+
if (!conn)
2178+
goto unlock;
2179+
2180+
if (conn->state == BT_CONNECTED) {
21782181
hci_conn_hold(conn);
21792182
conn->disc_timeout = HCI_PAIRING_TIMEOUT;
21802183
hci_conn_put(conn);
@@ -2194,6 +2197,7 @@ static inline void hci_pin_code_request_evt(struct hci_dev *hdev, struct sk_buff
21942197
mgmt_pin_code_request(hdev->id, &ev->bdaddr, secure);
21952198
}
21962199

2200+
unlock:
21972201
hci_dev_unlock(hdev);
21982202
}
21992203

0 commit comments

Comments
 (0)