aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2014-05-20 02:45:52 -0400
committerMarcel Holtmann <marcel@holtmann.org>2014-05-20 11:44:14 -0400
commit1cc6114402f864c3d090738df355d26c1fd374bb (patch)
tree6ff9b96afc5c92cbabdbf1e5dccc062ffa226113 /net
parent861580a970f1abe64193636eab9e5a1a7556a555 (diff)
Bluetooth: Update smp_confirm to return a response code
Now that smp_confirm() is called "inline" we can have it return a response code and have the sending of it be done in the shared place for command handlers. One exception is when we're entering smp.c from mgmt.c when user space responds to authentication, in which case we still need our own code to call smp_failure(). 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.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index fa782d7b495b..4f9662d0fd81 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -467,14 +467,13 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,
467 return ret; 467 return ret;
468} 468}
469 469
470static void smp_confirm(struct smp_chan *smp) 470static u8 smp_confirm(struct smp_chan *smp)
471{ 471{
472 struct l2cap_conn *conn = smp->conn; 472 struct l2cap_conn *conn = smp->conn;
473 struct hci_dev *hdev = conn->hcon->hdev; 473 struct hci_dev *hdev = conn->hcon->hdev;
474 struct crypto_blkcipher *tfm = hdev->tfm_aes; 474 struct crypto_blkcipher *tfm = hdev->tfm_aes;
475 struct smp_cmd_pairing_confirm cp; 475 struct smp_cmd_pairing_confirm cp;
476 int ret; 476 int ret;
477 u8 reason;
478 477
479 BT_DBG("conn %p", conn); 478 BT_DBG("conn %p", conn);
480 479
@@ -488,19 +487,14 @@ static void smp_confirm(struct smp_chan *smp)
488 487
489 hci_dev_unlock(hdev); 488 hci_dev_unlock(hdev);
490 489
491 if (ret) { 490 if (ret)
492 reason = SMP_UNSPECIFIED; 491 return SMP_UNSPECIFIED;
493 goto error;
494 }
495 492
496 clear_bit(SMP_FLAG_CFM_PENDING, &smp->flags); 493 clear_bit(SMP_FLAG_CFM_PENDING, &smp->flags);
497 494
498 smp_send_cmd(smp->conn, SMP_CMD_PAIRING_CONFIRM, sizeof(cp), &cp); 495 smp_send_cmd(smp->conn, SMP_CMD_PAIRING_CONFIRM, sizeof(cp), &cp);
499 496
500 return; 497 return 0;
501
502error:
503 smp_failure(conn, reason);
504} 498}
505 499
506static u8 smp_random(struct smp_chan *smp) 500static u8 smp_random(struct smp_chan *smp)
@@ -657,8 +651,11 @@ int smp_user_confirm_reply(struct hci_conn *hcon, u16 mgmt_op, __le32 passkey)
657 } 651 }
658 652
659 /* If it is our turn to send Pairing Confirm, do so now */ 653 /* If it is our turn to send Pairing Confirm, do so now */
660 if (test_bit(SMP_FLAG_CFM_PENDING, &smp->flags)) 654 if (test_bit(SMP_FLAG_CFM_PENDING, &smp->flags)) {
661 smp_confirm(smp); 655 u8 rsp = smp_confirm(smp);
656 if (rsp)
657 smp_failure(conn, rsp);
658 }
662 659
663 return 0; 660 return 0;
664} 661}
@@ -765,7 +762,7 @@ static u8 smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb)
765 762
766 /* Can't compose response until we have been confirmed */ 763 /* Can't compose response until we have been confirmed */
767 if (test_bit(SMP_FLAG_TK_VALID, &smp->flags)) 764 if (test_bit(SMP_FLAG_TK_VALID, &smp->flags))
768 smp_confirm(smp); 765 return smp_confirm(smp);
769 766
770 return 0; 767 return 0;
771} 768}
@@ -786,7 +783,7 @@ static u8 smp_cmd_pairing_confirm(struct l2cap_conn *conn, struct sk_buff *skb)
786 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd), 783 smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd),
787 smp->prnd); 784 smp->prnd);
788 else if (test_bit(SMP_FLAG_TK_VALID, &smp->flags)) 785 else if (test_bit(SMP_FLAG_TK_VALID, &smp->flags))
789 smp_confirm(smp); 786 return smp_confirm(smp);
790 else 787 else
791 set_bit(SMP_FLAG_CFM_PENDING, &smp->flags); 788 set_bit(SMP_FLAG_CFM_PENDING, &smp->flags);
792 789