Skip to content

Commit

Permalink
Bluetooth: Fix invalid memory access when there's no SMP channel
Browse files Browse the repository at this point in the history
We only should try to free the SMP channel that was created if there
is a pending SMP session.

Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
  • Loading branch information
Vinicius Costa Gomes authored and Johan Hedberg committed Feb 13, 2012
1 parent 66f0129 commit f1c09c0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions net/bluetooth/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,11 @@ static void smp_failure(struct l2cap_conn *conn, u8 reason, u8 send)

clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->hcon->flags);
mgmt_auth_failed(conn->hcon->hdev, conn->dst, reason);
cancel_delayed_work_sync(&conn->security_timer);
smp_chan_destroy(conn);

if (test_and_clear_bit(HCI_CONN_LE_SMP_PEND, &conn->hcon->flags)) {
cancel_delayed_work_sync(&conn->security_timer);
smp_chan_destroy(conn);
}
}

#define JUST_WORKS 0x00
Expand Down Expand Up @@ -506,7 +509,7 @@ void smp_chan_destroy(struct l2cap_conn *conn)
{
struct smp_chan *smp = conn->smp_chan;

clear_bit(HCI_CONN_LE_SMP_PEND, &conn->hcon->flags);
BUG_ON(!smp);

if (smp->tfm)
crypto_free_blkcipher(smp->tfm);
Expand Down

0 comments on commit f1c09c0

Please sign in to comment.