aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2013-01-20 07:27:16 -0500
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>2013-01-22 22:56:51 -0500
commit3f706b7205456c90cdc91e21eab36e2fcf4a8bce (patch)
tree291736a32da4624e99c1c651a7e5a456ed98ef9a /net
parent54ad6d8a5afe1a6d162d8d229a3d8fc48b254d24 (diff)
Bluetooth: Refactor valid LTK data testing into its own function
This patch refactors valid LTK data testing into its own function. This will help keep the code readable since there are several tests still missing that need to be done on the LTK data. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/mgmt.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index c7ec47ce94e5..cd758994b02f 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2701,6 +2701,13 @@ done:
2701 return err; 2701 return err;
2702} 2702}
2703 2703
2704static bool ltk_is_valid(struct mgmt_ltk_info *key)
2705{
2706 if (key->master != 0x00 && key->master != 0x01)
2707 return false;
2708 return true;
2709}
2710
2704static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev, 2711static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
2705 void *cp_data, u16 len) 2712 void *cp_data, u16 len)
2706{ 2713{
@@ -2724,7 +2731,7 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
2724 for (i = 0; i < key_count; i++) { 2731 for (i = 0; i < key_count; i++) {
2725 struct mgmt_ltk_info *key = &cp->keys[i]; 2732 struct mgmt_ltk_info *key = &cp->keys[i];
2726 2733
2727 if (key->master != 0x00 && key->master != 0x01) 2734 if (!ltk_is_valid(key))
2728 return cmd_status(sk, hdev->id, 2735 return cmd_status(sk, hdev->id,
2729 MGMT_OP_LOAD_LONG_TERM_KEYS, 2736 MGMT_OP_LOAD_LONG_TERM_KEYS,
2730 MGMT_STATUS_INVALID_PARAMS); 2737 MGMT_STATUS_INVALID_PARAMS);