Skip to content

Commit

Permalink
Bluetooth: Check address in mgmt_disconnect_failed()
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
  • Loading branch information
Andre Guedes authored and Gustavo Padovan committed Dec 4, 2013
1 parent 8a4934f commit 3655bba
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion net/bluetooth/mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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));
Expand Down

0 comments on commit 3655bba

Please sign in to comment.