Skip to content

Commit 0da71f1

Browse files
holtmannjhedberg
authored andcommitted
Bluetooth: Enable LE encryption events only when supported
The support for LE encryption is optional. When encryption is not supported then also do not enable the encryption related events. This moves the event mask setting to the third initialization stage to ensure that the LE features are available. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
1 parent 15a49cc commit 0da71f1

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

‎include/net/bluetooth/hci.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ enum {
329329
#define LMP_HOST_SC 0x08
330330

331331
/* LE features */
332+
#define HCI_LE_ENCRYPTION 0x01
332333
#define HCI_LE_CONN_PARAM_REQ_PROC 0x02
333334
#define HCI_LE_PING 0x10
334335

‎net/bluetooth/hci_core.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,14 +1422,17 @@ static void hci_setup_event_mask(struct hci_request *req)
14221422
/* Use a different default for LE-only devices */
14231423
memset(events, 0, sizeof(events));
14241424
events[0] |= 0x10; /* Disconnection Complete */
1425-
events[0] |= 0x80; /* Encryption Change */
14261425
events[1] |= 0x08; /* Read Remote Version Information Complete */
14271426
events[1] |= 0x20; /* Command Complete */
14281427
events[1] |= 0x40; /* Command Status */
14291428
events[1] |= 0x80; /* Hardware Error */
14301429
events[2] |= 0x04; /* Number of Completed Packets */
14311430
events[3] |= 0x02; /* Data Buffer Overflow */
1432-
events[5] |= 0x80; /* Encryption Key Refresh Complete */
1431+
1432+
if (hdev->le_features[0] & HCI_LE_ENCRYPTION) {
1433+
events[0] |= 0x80; /* Encryption Change */
1434+
events[5] |= 0x80; /* Encryption Key Refresh Complete */
1435+
}
14331436
}
14341437

14351438
if (lmp_inq_rssi_capable(hdev))
@@ -1482,8 +1485,6 @@ static void hci_init2_req(struct hci_request *req, unsigned long opt)
14821485
if (lmp_le_capable(hdev))
14831486
le_setup(req);
14841487

1485-
hci_setup_event_mask(req);
1486-
14871488
/* AVM Berlin (31), aka "BlueFRITZ!", doesn't support the read
14881489
* local supported commands HCI command.
14891490
*/
@@ -1611,6 +1612,8 @@ static void hci_init3_req(struct hci_request *req, unsigned long opt)
16111612
struct hci_dev *hdev = req->hdev;
16121613
u8 p;
16131614

1615+
hci_setup_event_mask(req);
1616+
16141617
/* Some Broadcom based Bluetooth controllers do not support the
16151618
* Delete Stored Link Key command. They are clearly indicating its
16161619
* absence in the bit mask of supported commands.

0 commit comments

Comments
 (0)