Skip to content

Commit 1cc6114

Browse files
Johan Hedbergholtmann
authored andcommitted
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 <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent 861580a commit 1cc6114

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

net/bluetooth/smp.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -467,14 +467,13 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,
467467
return ret;
468468
}
469469

470-
static void smp_confirm(struct smp_chan *smp)
470+
static u8 smp_confirm(struct smp_chan *smp)
471471
{
472472
struct l2cap_conn *conn = smp->conn;
473473
struct hci_dev *hdev = conn->hcon->hdev;
474474
struct crypto_blkcipher *tfm = hdev->tfm_aes;
475475
struct smp_cmd_pairing_confirm cp;
476476
int ret;
477-
u8 reason;
478477

479478
BT_DBG("conn %p", conn);
480479

@@ -488,19 +487,14 @@ static void smp_confirm(struct smp_chan *smp)
488487

489488
hci_dev_unlock(hdev);
490489

491-
if (ret) {
492-
reason = SMP_UNSPECIFIED;
493-
goto error;
494-
}
490+
if (ret)
491+
return SMP_UNSPECIFIED;
495492

496493
clear_bit(SMP_FLAG_CFM_PENDING, &smp->flags);
497494

498495
smp_send_cmd(smp->conn, SMP_CMD_PAIRING_CONFIRM, sizeof(cp), &cp);
499496

500-
return;
501-
502-
error:
503-
smp_failure(conn, reason);
497+
return 0;
504498
}
505499

506500
static 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)
657651
}
658652

659653
/* If it is our turn to send Pairing Confirm, do so now */
660-
if (test_bit(SMP_FLAG_CFM_PENDING, &smp->flags))
661-
smp_confirm(smp);
654+
if (test_bit(SMP_FLAG_CFM_PENDING, &smp->flags)) {
655+
u8 rsp = smp_confirm(smp);
656+
if (rsp)
657+
smp_failure(conn, rsp);
658+
}
662659

663660
return 0;
664661
}
@@ -765,7 +762,7 @@ static u8 smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb)
765762

766763
/* Can't compose response until we have been confirmed */
767764
if (test_bit(SMP_FLAG_TK_VALID, &smp->flags))
768-
smp_confirm(smp);
765+
return smp_confirm(smp);
769766

770767
return 0;
771768
}
@@ -786,7 +783,7 @@ static u8 smp_cmd_pairing_confirm(struct l2cap_conn *conn, struct sk_buff *skb)
786783
smp_send_cmd(conn, SMP_CMD_PAIRING_RANDOM, sizeof(smp->prnd),
787784
smp->prnd);
788785
else if (test_bit(SMP_FLAG_TK_VALID, &smp->flags))
789-
smp_confirm(smp);
786+
return smp_confirm(smp);
790787
else
791788
set_bit(SMP_FLAG_CFM_PENDING, &smp->flags);
792789

0 commit comments

Comments
 (0)