diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2014-08-18 13:33:31 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-09-08 13:07:54 -0400 |
commit | 9b7b18ef1bea82e5fc1e05da386ff57b0f60f651 (patch) | |
tree | 8557808cf1ff2dba573addc33f953ec8ddfcee7a /net/bluetooth/smp.c | |
parent | b04afa0c280b7e7ced88692251d75a78c8fcb2a7 (diff) |
Bluetooth: Fix SMP error and response to be mutually exclusive
Returning failure from the SMP data parsing function will cause an
immediate disconnect, making any attempts to send a response PDU futile.
This patch updates the function to always either send a response or
return an error, but never both at the same time:
* In the case that HCI_LE_ENABLED is not set we want to send a Pairing Not
Supported response but it is not required to force a disconnection, so
do not set the error return in this case.
* If we get garbage SMP data we can just fail with the handler function
instead of also trying to send an SMP Failure PDU.
* There's no reason to force a disconnection if we receive an unknown SMP
command. Instead simply send a proper Command Not Supported SMP
response.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/smp.c')
-rw-r--r-- | net/bluetooth/smp.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 496584921fdc..16c181181775 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c | |||
@@ -1430,7 +1430,6 @@ static int smp_sig_channel(struct l2cap_chan *chan, struct sk_buff *skb) | |||
1430 | return -EILSEQ; | 1430 | return -EILSEQ; |
1431 | 1431 | ||
1432 | if (!test_bit(HCI_LE_ENABLED, &hcon->hdev->dev_flags)) { | 1432 | if (!test_bit(HCI_LE_ENABLED, &hcon->hdev->dev_flags)) { |
1433 | err = -EOPNOTSUPP; | ||
1434 | reason = SMP_PAIRING_NOTSUPP; | 1433 | reason = SMP_PAIRING_NOTSUPP; |
1435 | goto done; | 1434 | goto done; |
1436 | } | 1435 | } |
@@ -1447,7 +1446,6 @@ static int smp_sig_channel(struct l2cap_chan *chan, struct sk_buff *skb) | |||
1447 | if (code != SMP_CMD_PAIRING_REQ && code != SMP_CMD_SECURITY_REQ && | 1446 | if (code != SMP_CMD_PAIRING_REQ && code != SMP_CMD_SECURITY_REQ && |
1448 | !test_bit(HCI_CONN_LE_SMP_PEND, &hcon->flags)) { | 1447 | !test_bit(HCI_CONN_LE_SMP_PEND, &hcon->flags)) { |
1449 | BT_ERR("Unexpected SMP command 0x%02x. Disconnecting.", code); | 1448 | BT_ERR("Unexpected SMP command 0x%02x. Disconnecting.", code); |
1450 | reason = SMP_CMD_NOTSUPP; | ||
1451 | err = -EOPNOTSUPP; | 1449 | err = -EOPNOTSUPP; |
1452 | goto done; | 1450 | goto done; |
1453 | } | 1451 | } |
@@ -1459,7 +1457,6 @@ static int smp_sig_channel(struct l2cap_chan *chan, struct sk_buff *skb) | |||
1459 | 1457 | ||
1460 | case SMP_CMD_PAIRING_FAIL: | 1458 | case SMP_CMD_PAIRING_FAIL: |
1461 | smp_failure(conn, 0); | 1459 | smp_failure(conn, 0); |
1462 | reason = 0; | ||
1463 | err = -EPERM; | 1460 | err = -EPERM; |
1464 | break; | 1461 | break; |
1465 | 1462 | ||
@@ -1501,17 +1498,17 @@ static int smp_sig_channel(struct l2cap_chan *chan, struct sk_buff *skb) | |||
1501 | 1498 | ||
1502 | default: | 1499 | default: |
1503 | BT_DBG("Unknown command code 0x%2.2x", code); | 1500 | BT_DBG("Unknown command code 0x%2.2x", code); |
1504 | |||
1505 | reason = SMP_CMD_NOTSUPP; | 1501 | reason = SMP_CMD_NOTSUPP; |
1506 | err = -EOPNOTSUPP; | ||
1507 | goto done; | 1502 | goto done; |
1508 | } | 1503 | } |
1509 | 1504 | ||
1510 | done: | 1505 | done: |
1511 | if (reason) | 1506 | if (!err) { |
1512 | smp_failure(conn, reason); | 1507 | if (reason) |
1513 | if (!err) | 1508 | smp_failure(conn, reason); |
1514 | kfree_skb(skb); | 1509 | kfree_skb(skb); |
1510 | } | ||
1511 | |||
1515 | return err; | 1512 | return err; |
1516 | } | 1513 | } |
1517 | 1514 | ||