diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2014-05-20 02:45:51 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-05-20 11:44:14 -0400 |
commit | 861580a970f1abe64193636eab9e5a1a7556a555 (patch) | |
tree | 401d745a4388d5e84edc0ded17857c084a88ab53 /net | |
parent | 4a74d65868f10dafe38765d4fe5bbf1e75f0623d (diff) |
Bluetooth: Update smp_random to return a response code
Since we're now calling smp_random() "inline" we can have it directly
return a response code and have the shared command handler send the
response.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/bluetooth/smp.c | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 8d1a1903e458..fa782d7b495b 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c | |||
@@ -503,19 +503,17 @@ error: | |||
503 | smp_failure(conn, reason); | 503 | smp_failure(conn, reason); |
504 | } | 504 | } |
505 | 505 | ||
506 | static void smp_random(struct smp_chan *smp) | 506 | static u8 smp_random(struct smp_chan *smp) |
507 | { | 507 | { |
508 | struct l2cap_conn *conn = smp->conn; | 508 | struct l2cap_conn *conn = smp->conn; |
509 | struct hci_conn *hcon = conn->hcon; | 509 | struct hci_conn *hcon = conn->hcon; |
510 | struct hci_dev *hdev = hcon->hdev; | 510 | struct hci_dev *hdev = hcon->hdev; |
511 | struct crypto_blkcipher *tfm = hdev->tfm_aes; | 511 | struct crypto_blkcipher *tfm = hdev->tfm_aes; |
512 | u8 reason, confirm[16]; | 512 | u8 confirm[16]; |
513 | int ret; | 513 | int ret; |
514 | 514 | ||
515 | if (IS_ERR_OR_NULL(tfm)) { | 515 | if (IS_ERR_OR_NULL(tfm)) |
516 | reason = SMP_UNSPECIFIED; | 516 | return SMP_UNSPECIFIED; |
517 | goto error; | ||
518 | } | ||
519 | 517 | ||
520 | BT_DBG("conn %p %s", conn, conn->hcon->out ? "master" : "slave"); | 518 | BT_DBG("conn %p %s", conn, conn->hcon->out ? "master" : "slave"); |
521 | 519 | ||
@@ -528,15 +526,12 @@ static void smp_random(struct smp_chan *smp) | |||
528 | 526 | ||
529 | hci_dev_unlock(hdev); | 527 | hci_dev_unlock(hdev); |
530 | 528 | ||
531 | if (ret) { | 529 | if (ret) |
532 | reason = SMP_UNSPECIFIED; | 530 | return SMP_UNSPECIFIED; |
533 | goto error; | ||
534 | } | ||
535 | 531 | ||
536 | if (memcmp(smp->pcnf, confirm, sizeof(smp->pcnf)) != 0) { | 532 | if (memcmp(smp->pcnf, confirm, sizeof(smp->pcnf)) != 0) { |
537 | BT_ERR("Pairing failed (confirmation values mismatch)"); | 533 | BT_ERR("Pairing failed (confirmation values mismatch)"); |
538 | reason = SMP_CONFIRM_FAILED; | 534 | return SMP_CONFIRM_FAILED; |
539 | goto error; | ||
540 | } | 535 | } |
541 | 536 | ||
542 | if (hcon->out) { | 537 | if (hcon->out) { |
@@ -549,10 +544,8 @@ static void smp_random(struct smp_chan *smp) | |||
549 | memset(stk + smp->enc_key_size, 0, | 544 | memset(stk + smp->enc_key_size, 0, |
550 | SMP_MAX_ENC_KEY_SIZE - smp->enc_key_size); | 545 | SMP_MAX_ENC_KEY_SIZE - smp->enc_key_size); |
551 | 546 | ||
552 | if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &hcon->flags)) { | 547 | if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &hcon->flags)) |
553 | reason = SMP_UNSPECIFIED; | 548 | return SMP_UNSPECIFIED; |
554 | goto error; | ||
555 | } | ||
556 | 549 | ||
557 | hci_le_start_enc(hcon, ediv, rand, stk); | 550 | hci_le_start_enc(hcon, ediv, rand, stk); |
558 | hcon->enc_key_size = smp->enc_key_size; | 551 | hcon->enc_key_size = smp->enc_key_size; |
@@ -574,10 +567,7 @@ static void smp_random(struct smp_chan *smp) | |||
574 | ediv, rand); | 567 | ediv, rand); |
575 | } | 568 | } |
576 | 569 | ||
577 | return; | 570 | return 0; |
578 | |||
579 | error: | ||
580 | smp_failure(conn, reason); | ||
581 | } | 571 | } |
582 | 572 | ||
583 | static struct smp_chan *smp_chan_create(struct l2cap_conn *conn) | 573 | static struct smp_chan *smp_chan_create(struct l2cap_conn *conn) |
@@ -815,9 +805,7 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb) | |||
815 | memcpy(smp->rrnd, skb->data, sizeof(smp->rrnd)); | 805 | memcpy(smp->rrnd, skb->data, sizeof(smp->rrnd)); |
816 | skb_pull(skb, sizeof(smp->rrnd)); | 806 | skb_pull(skb, sizeof(smp->rrnd)); |
817 | 807 | ||
818 | smp_random(smp); | 808 | return smp_random(smp); |
819 | |||
820 | return 0; | ||
821 | } | 809 | } |
822 | 810 | ||
823 | static u8 smp_ltk_encrypt(struct l2cap_conn *conn, u8 sec_level) | 811 | static u8 smp_ltk_encrypt(struct l2cap_conn *conn, u8 sec_level) |