linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hedberg <johan.hedberg@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH 04/10] Bluetooth: Refactor valid LTK data testing into its own function
Date: Fri, 18 Jan 2013 15:25:52 +0200	[thread overview]
Message-ID: <1358515558-17861-5-git-send-email-johan.hedberg@gmail.com> (raw)
In-Reply-To: <1358515558-17861-1-git-send-email-johan.hedberg@gmail.com>

From: Johan Hedberg <johan.hedberg@intel.com>

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.
---
 net/bluetooth/mgmt.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 5388151..3634907 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2701,6 +2701,13 @@ done:
 	return err;
 }
 
+static bool ltk_is_valid(struct mgmt_ltk_info *key)
+{
+	if (key->master != 0x00 && key->master != 0x01)
+		return false;
+	return true;
+}
+
 static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
 			       void *cp_data, u16 len)
 {
@@ -2729,7 +2736,7 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev,
 		struct mgmt_ltk_info *key = &cp->keys[i];
 		u8 type;
 
-		if (key->master != 0x00 && key->master != 0x01) {
+		if (!ltk_is_valid(key)) {
 			hci_smp_ltks_clear(hdev);
 			err = cmd_status(sk, hdev->id,
 					 MGMT_OP_LOAD_LONG_TERM_KEYS,
-- 
1.7.10.4


  parent reply	other threads:[~2013-01-18 13:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-18 13:25 [PATCH 00/10] Bluetooth: Fix more mgmt parameter checks Johan Hedberg
2013-01-18 13:25 ` [PATCH 01/10] Bluetooth: Fix checking for correct mgmt_load_link_keys parameters Johan Hedberg
2013-01-18 16:55   ` Marcel Holtmann
2013-01-18 13:25 ` [PATCH 02/10] Bluetooth: Fix returning proper mgmt status for Load LTKs Johan Hedberg
2013-01-18 16:55   ` Marcel Holtmann
2013-01-18 13:25 ` [PATCH 03/10] Bluetooth: Fix checking for proper key->master value in " Johan Hedberg
2013-01-18 13:25 ` Johan Hedberg [this message]
2013-01-18 13:25 ` [PATCH 05/10] Bluetooth: Check for valid key->authenticated value for LTKs Johan Hedberg
2013-01-18 13:25 ` [PATCH 06/10] Bluetooth: Add helper functions for testing bdaddr types Johan Hedberg
2013-01-18 13:25 ` [PATCH 07/10] Bluetooth: Fix checking for valid address type values in mgmt commands Johan Hedberg
2013-01-18 16:53   ` Marcel Holtmann
2013-01-18 13:25 ` [PATCH 08/10] Bluetooth: Fix checking for valid disconnect parameters in unpair_device Johan Hedberg
2013-01-18 16:54   ` Marcel Holtmann
2013-01-18 13:25 ` [PATCH 09/10] Bluetooth: Fix returning proper cmd_complete for mgmt_disconnect Johan Hedberg
2013-01-18 13:25 ` [PATCH 10/10] Bluetooth: Fix returning proper cmd_complete for mgmt_block/unblock Johan Hedberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1358515558-17861-5-git-send-email-johan.hedberg@gmail.com \
    --to=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).