Skip to content

Commit a514b17

Browse files
finikorgGustavo Padovan
authored andcommitted
Bluetooth: Refactor locking in amp_physical_cfm
Remove locking from l2cap_physical_cfm and lock chan inside amp_physical_cfm. Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
1 parent 522db70 commit a514b17

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

‎include/net/bluetooth/l2cap.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,6 @@ void l2cap_send_conn_req(struct l2cap_chan *chan);
811811
void l2cap_move_start(struct l2cap_chan *chan);
812812
void l2cap_logical_cfm(struct l2cap_chan *chan, struct hci_chan *hchan,
813813
u8 status);
814-
void l2cap_physical_cfm(struct l2cap_chan *chan, int result);
814+
void __l2cap_physical_cfm(struct l2cap_chan *chan, int result);
815815

816816
#endif /* __L2CAP_H */

‎net/bluetooth/amp.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,17 @@ void amp_physical_cfm(struct hci_conn *bredr_hcon, struct hci_conn *hs_hcon)
386386

387387
bredr_chan = mgr->bredr_chan;
388388

389+
l2cap_chan_lock(bredr_chan);
390+
389391
set_bit(FLAG_EFS_ENABLE, &bredr_chan->flags);
390392
bredr_chan->remote_amp_id = hs_hcon->remote_id;
391393
bredr_chan->hs_hcon = hs_hcon;
392394
bredr_chan->conn->mtu = hs_hcon->hdev->block_mtu;
393395
bredr_chan->fcs = L2CAP_FCS_NONE;
394396

395-
l2cap_physical_cfm(bredr_chan, 0);
397+
__l2cap_physical_cfm(bredr_chan, 0);
398+
399+
l2cap_chan_unlock(bredr_chan);
396400

397401
hci_dev_put(bredr_hdev);
398402
}

‎net/bluetooth/l2cap_core.c‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4611,16 +4611,15 @@ static void l2cap_do_move_cancel(struct l2cap_chan *chan, int result)
46114611
l2cap_ertm_send(chan);
46124612
}
46134613

4614-
void l2cap_physical_cfm(struct l2cap_chan *chan, int result)
4614+
/* Invoke with locked chan */
4615+
void __l2cap_physical_cfm(struct l2cap_chan *chan, int result)
46154616
{
46164617
u8 local_amp_id = chan->local_amp_id;
46174618
u8 remote_amp_id = chan->remote_amp_id;
46184619

46194620
BT_DBG("chan %p, result %d, local_amp_id %d, remote_amp_id %d",
46204621
chan, result, local_amp_id, remote_amp_id);
46214622

4622-
l2cap_chan_lock(chan);
4623-
46244623
if (chan->state == BT_DISCONN || chan->state == BT_CLOSED) {
46254624
l2cap_chan_unlock(chan);
46264625
return;
@@ -4644,8 +4643,6 @@ void l2cap_physical_cfm(struct l2cap_chan *chan, int result)
46444643
break;
46454644
}
46464645
}
4647-
4648-
l2cap_chan_unlock(chan);
46494646
}
46504647

46514648
static inline int l2cap_move_channel_req(struct l2cap_conn *conn,

0 commit comments

Comments
 (0)