diff options
Diffstat (limited to 'net/bluetooth/smp.c')
| -rw-r--r-- | net/bluetooth/smp.c | 16 | 
1 files changed, 13 insertions, 3 deletions
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index ae91e2d40056..3a7b0773536b 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c @@ -83,6 +83,7 @@ enum {  struct smp_dev {  	/* Secure Connections OOB data */ +	bool			local_oob;  	u8			local_pk[64];  	u8			local_rand[16];  	bool			debug_key; @@ -599,6 +600,8 @@ int smp_generate_oob(struct hci_dev *hdev, u8 hash[16], u8 rand[16])  	memcpy(rand, smp->local_rand, 16); +	smp->local_oob = true; +  	return 0;  } @@ -1785,7 +1788,7 @@ static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb)  	 * successfully received our local OOB data - therefore set the  	 * flag to indicate that local OOB is in use.  	 */ -	if (req->oob_flag == SMP_OOB_PRESENT) +	if (req->oob_flag == SMP_OOB_PRESENT && SMP_DEV(hdev)->local_oob)  		set_bit(SMP_FLAG_LOCAL_OOB, &smp->flags);  	/* SMP over BR/EDR requires special treatment */ @@ -1967,7 +1970,7 @@ static u8 smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb)  	 * successfully received our local OOB data - therefore set the  	 * flag to indicate that local OOB is in use.  	 */ -	if (rsp->oob_flag == SMP_OOB_PRESENT) +	if (rsp->oob_flag == SMP_OOB_PRESENT && SMP_DEV(hdev)->local_oob)  		set_bit(SMP_FLAG_LOCAL_OOB, &smp->flags);  	smp->prsp[0] = SMP_CMD_PAIRING_RSP; @@ -2697,7 +2700,13 @@ static int smp_cmd_public_key(struct l2cap_conn *conn, struct sk_buff *skb)  	 * key was set/generated.  	 */  	if (test_bit(SMP_FLAG_LOCAL_OOB, &smp->flags)) { -		struct smp_dev *smp_dev = chan->data; +		struct l2cap_chan *hchan = hdev->smp_data; +		struct smp_dev *smp_dev; + +		if (!hchan || !hchan->data) +			return SMP_UNSPECIFIED; + +		smp_dev = hchan->data;  		tfm_ecdh = smp_dev->tfm_ecdh;  	} else { @@ -3230,6 +3239,7 @@ static struct l2cap_chan *smp_add_cid(struct hci_dev *hdev, u16 cid)  		return ERR_CAST(tfm_ecdh);  	} +	smp->local_oob = false;  	smp->tfm_aes = tfm_aes;  	smp->tfm_cmac = tfm_cmac;  	smp->tfm_ecdh = tfm_ecdh;  |