From: Andre Guedes <andre.guedes@openbossa.org>
To: linux-bluetooth@vger.kernel.org
Subject: [RFC 1/5] Bluetooth: Check address in mgmt_disconnect_failed()
Date: Wed, 30 Oct 2013 19:01:40 -0300 [thread overview]
Message-ID: <1383170504-16602-2-git-send-email-andre.guedes@openbossa.org> (raw)
In-Reply-To: <1383170504-16602-1-git-send-email-andre.guedes@openbossa.org>
Check the address and address type in mgmt_disconnect_failed() otherwise
we may wrongly fail the MGMT_OP_DISCONNECT command.
Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
---
net/bluetooth/mgmt.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 22cf547..6a74aa7 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -4613,6 +4613,8 @@ void mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr,
void mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr,
u8 link_type, u8 addr_type, u8 status)
{
+ u8 bdaddr_type = link_to_bdaddr(link_type, addr_type);
+ struct mgmt_cp_disconnect *cp;
struct mgmt_rp_disconnect rp;
struct pending_cmd *cmd;
@@ -4623,8 +4625,16 @@ void mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr,
if (!cmd)
return;
+ cp = cmd->param;
+
+ if (bacmp(bdaddr, &cp->addr.bdaddr))
+ return;
+
+ if (cp->addr.type != bdaddr_type)
+ return;
+
bacpy(&rp.addr.bdaddr, bdaddr);
- rp.addr.type = link_to_bdaddr(link_type, addr_type);
+ rp.addr.type = bdaddr_type;
cmd_complete(cmd->sk, cmd->index, MGMT_OP_DISCONNECT,
mgmt_status(status), &rp, sizeof(rp));
--
1.8.4
next prev parent reply other threads:[~2013-10-30 22:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-30 22:01 [RFC 0/5] Disconnect complete refactoring Andre Guedes
2013-10-30 22:01 ` Andre Guedes [this message]
2013-10-30 22:01 ` [RFC 2/5] Bluetooth: Add an extra check in mgmt_device_disconnected() Andre Guedes
2013-10-30 22:01 ` [RFC 3/5] Bluetooth: Remove link type check in hci_disconn_complete_evt() Andre Guedes
2013-10-30 22:01 ` [RFC 4/5] Bluetooth: Remove unneeded " Andre Guedes
2013-11-02 18:14 ` Marcel Holtmann
2013-11-04 17:15 ` Andre Guedes
2013-10-30 22:01 ` [RFC 5/5] Bluetooth: Refactor hci_disconn_complete_evt Andre Guedes
2013-11-02 18:17 ` [RFC 0/5] Disconnect complete refactoring Marcel Holtmann
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=1383170504-16602-2-git-send-email-andre.guedes@openbossa.org \
--to=andre.guedes@openbossa.org \
--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