@@ -2897,7 +2897,8 @@ static int load_link_keys(struct sock *sk, struct hci_dev *hdev, void *data,
28972897 for (i = 0 ; i < key_count ; i ++ ) {
28982898 struct mgmt_link_key_info * key = & cp -> keys [i ];
28992899
2900- if (key -> addr .type != BDADDR_BREDR || key -> type > 0x08 )
2900+ /* Considering SMP over BREDR/LE, there is no need to check addr_type */
2901+ if (key -> type > 0x08 )
29012902 return mgmt_cmd_status (sk , hdev -> id ,
29022903 MGMT_OP_LOAD_LINK_KEYS ,
29032904 MGMT_STATUS_INVALID_PARAMS );
@@ -7130,6 +7131,7 @@ static int load_irks(struct sock *sk, struct hci_dev *hdev, void *cp_data,
71307131
71317132 for (i = 0 ; i < irk_count ; i ++ ) {
71327133 struct mgmt_irk_info * irk = & cp -> irks [i ];
7134+ u8 addr_type = le_addr_type (irk -> addr .type );
71337135
71347136 if (hci_is_blocked_key (hdev ,
71357137 HCI_BLOCKED_KEY_TYPE_IRK ,
@@ -7139,8 +7141,12 @@ static int load_irks(struct sock *sk, struct hci_dev *hdev, void *cp_data,
71397141 continue ;
71407142 }
71417143
7144+ /* When using SMP over BR/EDR, the addr type should be set to BREDR */
7145+ if (irk -> addr .type == BDADDR_BREDR )
7146+ addr_type = BDADDR_BREDR ;
7147+
71427148 hci_add_irk (hdev , & irk -> addr .bdaddr ,
7143- le_addr_type ( irk -> addr . type ) , irk -> val ,
7149+ addr_type , irk -> val ,
71447150 BDADDR_ANY );
71457151 }
71467152
@@ -7221,6 +7227,7 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
72217227 for (i = 0 ; i < key_count ; i ++ ) {
72227228 struct mgmt_ltk_info * key = & cp -> keys [i ];
72237229 u8 type , authenticated ;
7230+ u8 addr_type = le_addr_type (key -> addr .type );
72247231
72257232 if (hci_is_blocked_key (hdev ,
72267233 HCI_BLOCKED_KEY_TYPE_LTK ,
@@ -7255,8 +7262,12 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
72557262 continue ;
72567263 }
72577264
7265+ /* When using SMP over BR/EDR, the addr type should be set to BREDR */
7266+ if (key -> addr .type == BDADDR_BREDR )
7267+ addr_type = BDADDR_BREDR ;
7268+
72587269 hci_add_ltk (hdev , & key -> addr .bdaddr ,
7259- le_addr_type ( key -> addr . type ) , type , authenticated ,
7270+ addr_type , type , authenticated ,
72607271 key -> val , key -> enc_size , key -> ediv , key -> rand );
72617272 }
72627273
@@ -9523,7 +9534,7 @@ void mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key,
95239534
95249535 ev .store_hint = persistent ;
95259536 bacpy (& ev .key .addr .bdaddr , & key -> bdaddr );
9526- ev .key .addr .type = BDADDR_BREDR ;
9537+ ev .key .addr .type = link_to_bdaddr ( key -> link_type , key -> bdaddr_type ) ;
95279538 ev .key .type = key -> type ;
95289539 memcpy (ev .key .val , key -> val , HCI_LINK_KEY_SIZE );
95299540 ev .key .pin_len = key -> pin_len ;
@@ -9574,7 +9585,7 @@ void mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, bool persistent)
95749585 ev .store_hint = persistent ;
95759586
95769587 bacpy (& ev .key .addr .bdaddr , & key -> bdaddr );
9577- ev .key .addr .type = link_to_bdaddr (LE_LINK , key -> bdaddr_type );
9588+ ev .key .addr .type = link_to_bdaddr (key -> link_type , key -> bdaddr_type );
95789589 ev .key .type = mgmt_ltk_type (key );
95799590 ev .key .enc_size = key -> enc_size ;
95809591 ev .key .ediv = key -> ediv ;
@@ -9603,7 +9614,7 @@ void mgmt_new_irk(struct hci_dev *hdev, struct smp_irk *irk, bool persistent)
96039614
96049615 bacpy (& ev .rpa , & irk -> rpa );
96059616 bacpy (& ev .irk .addr .bdaddr , & irk -> bdaddr );
9606- ev .irk .addr .type = link_to_bdaddr (LE_LINK , irk -> addr_type );
9617+ ev .irk .addr .type = link_to_bdaddr (irk -> link_type , irk -> addr_type );
96079618 memcpy (ev .irk .val , irk -> val , sizeof (irk -> val ));
96089619
96099620 mgmt_event (MGMT_EV_NEW_IRK , hdev , & ev , sizeof (ev ), NULL );
@@ -9632,7 +9643,7 @@ void mgmt_new_csrk(struct hci_dev *hdev, struct smp_csrk *csrk,
96329643 ev .store_hint = persistent ;
96339644
96349645 bacpy (& ev .key .addr .bdaddr , & csrk -> bdaddr );
9635- ev .key .addr .type = link_to_bdaddr (LE_LINK , csrk -> bdaddr_type );
9646+ ev .key .addr .type = link_to_bdaddr (csrk -> link_type , csrk -> bdaddr_type );
96369647 ev .key .type = csrk -> type ;
96379648 memcpy (ev .key .val , csrk -> val , sizeof (csrk -> val ));
96389649
0 commit comments