Skip to content

Commit 71fb419

Browse files
Johan Hedbergholtmann
authored andcommitted
Bluetooth: Fix handling of L2CAP Command Reject over LE
If we receive an L2CAP command reject message over LE we should take appropriate action on the corresponding channel. This is particularly important when trying to interact with a remote pre-4.1 system using LE CoC signaling messages. If we don't react to the command reject the corresponding socket would not be notified until a connection timeout occurs. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
1 parent 53b834d commit 71fb419

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

net/bluetooth/l2cap_core.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5736,6 +5736,31 @@ static inline int l2cap_le_credits(struct l2cap_conn *conn,
57365736
return 0;
57375737
}
57385738

5739+
static inline int l2cap_le_command_rej(struct l2cap_conn *conn,
5740+
struct l2cap_cmd_hdr *cmd, u16 cmd_len,
5741+
u8 *data)
5742+
{
5743+
struct l2cap_cmd_rej_unk *rej = (struct l2cap_cmd_rej_unk *) data;
5744+
struct l2cap_chan *chan;
5745+
5746+
if (cmd_len < sizeof(*rej))
5747+
return -EPROTO;
5748+
5749+
mutex_lock(&conn->chan_lock);
5750+
5751+
chan = __l2cap_get_chan_by_ident(conn, cmd->ident);
5752+
if (!chan)
5753+
goto done;
5754+
5755+
l2cap_chan_lock(chan);
5756+
l2cap_chan_del(chan, ECONNREFUSED);
5757+
l2cap_chan_unlock(chan);
5758+
5759+
done:
5760+
mutex_unlock(&conn->chan_lock);
5761+
return 0;
5762+
}
5763+
57395764
static inline int l2cap_le_sig_cmd(struct l2cap_conn *conn,
57405765
struct l2cap_cmd_hdr *cmd, u16 cmd_len,
57415766
u8 *data)
@@ -5755,6 +5780,7 @@ static inline int l2cap_le_sig_cmd(struct l2cap_conn *conn,
57555780

57565781
switch (cmd->code) {
57575782
case L2CAP_COMMAND_REJ:
5783+
l2cap_le_command_rej(conn, cmd, cmd_len, data);
57585784
break;
57595785

57605786
case L2CAP_CONN_PARAM_UPDATE_REQ:

0 commit comments

Comments
 (0)