diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2014-09-05 15:19:50 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-09-08 13:07:55 -0400 |
commit | f3d82d0c8ec025fc113408e3ad5775fed5a060ff (patch) | |
tree | 9b436aa3ad6613171c0a9646188bc24587299980 /net/bluetooth | |
parent | 84bc0db53b3a425fb992d5fed25b575e4434167a (diff) |
Bluetooth: Move identity address update behind a workqueue
The identity address update of all channels for an l2cap_conn needs to
take the lock for each channel, i.e. it's safest to do this by a
separate workqueue callback.
Previously this was partially solved by moving the entire SMP key
distribution behind a workqueue. However, if we want SMP context locking
to be correct and safe we should always use the l2cap_chan lock when
accessing it, meaning even smp_distribute_keys needs to take that lock
which would once again create a dead lock when updating the identity
address.
The simplest way to solve this is to have l2cap_conn manage the deferred
work which is what this patch does. A subsequent patch will remove the
now unnecessary SMP key distribution work struct.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/l2cap_core.c | 10 | ||||
-rw-r--r-- | net/bluetooth/smp.c | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index ab405f0e53cb..b71430caab4a 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -631,9 +631,11 @@ void l2cap_chan_del(struct l2cap_chan *chan, int err) | |||
631 | } | 631 | } |
632 | EXPORT_SYMBOL_GPL(l2cap_chan_del); | 632 | EXPORT_SYMBOL_GPL(l2cap_chan_del); |
633 | 633 | ||
634 | void l2cap_conn_update_id_addr(struct hci_conn *hcon) | 634 | static void l2cap_conn_update_id_addr(struct work_struct *work) |
635 | { | 635 | { |
636 | struct l2cap_conn *conn = hcon->l2cap_data; | 636 | struct l2cap_conn *conn = container_of(work, struct l2cap_conn, |
637 | id_addr_update_work); | ||
638 | struct hci_conn *hcon = conn->hcon; | ||
637 | struct l2cap_chan *chan; | 639 | struct l2cap_chan *chan; |
638 | 640 | ||
639 | mutex_lock(&conn->chan_lock); | 641 | mutex_lock(&conn->chan_lock); |
@@ -1635,6 +1637,9 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err) | |||
1635 | if (work_pending(&conn->pending_rx_work)) | 1637 | if (work_pending(&conn->pending_rx_work)) |
1636 | cancel_work_sync(&conn->pending_rx_work); | 1638 | cancel_work_sync(&conn->pending_rx_work); |
1637 | 1639 | ||
1640 | if (work_pending(&conn->id_addr_update_work)) | ||
1641 | cancel_work_sync(&conn->id_addr_update_work); | ||
1642 | |||
1638 | l2cap_unregister_all_users(conn); | 1643 | l2cap_unregister_all_users(conn); |
1639 | 1644 | ||
1640 | /* Force the connection to be immediately dropped */ | 1645 | /* Force the connection to be immediately dropped */ |
@@ -6927,6 +6932,7 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon) | |||
6927 | 6932 | ||
6928 | skb_queue_head_init(&conn->pending_rx); | 6933 | skb_queue_head_init(&conn->pending_rx); |
6929 | INIT_WORK(&conn->pending_rx_work, process_pending_rx); | 6934 | INIT_WORK(&conn->pending_rx_work, process_pending_rx); |
6935 | INIT_WORK(&conn->id_addr_update_work, l2cap_conn_update_id_addr); | ||
6930 | 6936 | ||
6931 | conn->disc_reason = HCI_ERROR_REMOTE_USER_TERM; | 6937 | conn->disc_reason = HCI_ERROR_REMOTE_USER_TERM; |
6932 | 6938 | ||
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 9accb4739488..795c603bed30 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c | |||
@@ -654,7 +654,7 @@ static void smp_notify_keys(struct l2cap_conn *conn) | |||
654 | */ | 654 | */ |
655 | bacpy(&hcon->dst, &smp->remote_irk->bdaddr); | 655 | bacpy(&hcon->dst, &smp->remote_irk->bdaddr); |
656 | hcon->dst_type = smp->remote_irk->addr_type; | 656 | hcon->dst_type = smp->remote_irk->addr_type; |
657 | l2cap_conn_update_id_addr(hcon); | 657 | queue_work(hdev->workqueue, &conn->id_addr_update_work); |
658 | 658 | ||
659 | /* When receiving an indentity resolving key for | 659 | /* When receiving an indentity resolving key for |
660 | * a remote device that does not use a resolvable | 660 | * a remote device that does not use a resolvable |