diff options
author | Brian Gix <bgix@codeaurora.org> | 2011-11-23 11:28:36 -0500 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-12-01 08:54:37 -0500 |
commit | 4f957a76014fb63d193cd6c141bdd94aaff3a25e (patch) | |
tree | fb96337b5e9c705ac587a800f3342edf000efd89 | |
parent | c8eb969071032defb1dc493ae28cf2e2a31193a5 (diff) |
Bluetooth: Centralize SMP pairing failure handling
Signed-off-by: Brian Gix <bgix@codeaurora.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
-rw-r--r-- | net/bluetooth/smp.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index b9af4885ae53..0b96737d0ad3 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c | |||
@@ -232,6 +232,18 @@ static u8 check_enc_key_size(struct l2cap_conn *conn, __u8 max_key_size) | |||
232 | return 0; | 232 | return 0; |
233 | } | 233 | } |
234 | 234 | ||
235 | static void smp_failure(struct l2cap_conn *conn, u8 reason, u8 send) | ||
236 | { | ||
237 | if (send) | ||
238 | smp_send_cmd(conn, SMP_CMD_PAIRING_FAIL, sizeof(reason), | ||
239 | &reason); | ||
240 | |||
241 | clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->hcon->pend); | ||
242 | mgmt_auth_failed(conn->hcon->hdev, conn->dst, reason); | ||
243 | del_timer(&conn->security_timer); | ||
244 | smp_chan_destroy(conn); | ||
245 | } | ||
246 | |||
235 | static void confirm_work(struct work_struct *work) | 247 | static void confirm_work(struct work_struct *work) |
236 | { | 248 | { |
237 | struct smp_chan *smp = container_of(work, struct smp_chan, confirm); | 249 | struct smp_chan *smp = container_of(work, struct smp_chan, confirm); |
@@ -270,8 +282,7 @@ static void confirm_work(struct work_struct *work) | |||
270 | return; | 282 | return; |
271 | 283 | ||
272 | error: | 284 | error: |
273 | smp_send_cmd(conn, SMP_CMD_PAIRING_FAIL, sizeof(reason), &reason); | 285 | smp_failure(conn, reason, 1); |
274 | smp_chan_destroy(conn); | ||
275 | } | 286 | } |
276 | 287 | ||
277 | static void random_work(struct work_struct *work) | 288 | static void random_work(struct work_struct *work) |
@@ -354,8 +365,7 @@ static void random_work(struct work_struct *work) | |||
354 | return; | 365 | return; |
355 | 366 | ||
356 | error: | 367 | error: |
357 | smp_send_cmd(conn, SMP_CMD_PAIRING_FAIL, sizeof(reason), &reason); | 368 | smp_failure(conn, reason, 1); |
358 | smp_chan_destroy(conn); | ||
359 | } | 369 | } |
360 | 370 | ||
361 | static struct smp_chan *smp_chan_create(struct l2cap_conn *conn) | 371 | static struct smp_chan *smp_chan_create(struct l2cap_conn *conn) |
@@ -655,6 +665,7 @@ int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb) | |||
655 | break; | 665 | break; |
656 | 666 | ||
657 | case SMP_CMD_PAIRING_FAIL: | 667 | case SMP_CMD_PAIRING_FAIL: |
668 | smp_failure(conn, skb->data[0], 0); | ||
658 | reason = 0; | 669 | reason = 0; |
659 | err = -EPERM; | 670 | err = -EPERM; |
660 | break; | 671 | break; |
@@ -700,8 +711,7 @@ int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb) | |||
700 | 711 | ||
701 | done: | 712 | done: |
702 | if (reason) | 713 | if (reason) |
703 | smp_send_cmd(conn, SMP_CMD_PAIRING_FAIL, sizeof(reason), | 714 | smp_failure(conn, reason, 1); |
704 | &reason); | ||
705 | 715 | ||
706 | kfree_skb(skb); | 716 | kfree_skb(skb); |
707 | return err; | 717 | return err; |