Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Johan Hedberg and committed by
Marcel Holtmann
71fb4197 53b834d2

+26
+26
net/bluetooth/l2cap_core.c
··· 5736 5736 return 0; 5737 5737 } 5738 5738 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 + 5739 5764 static inline int l2cap_le_sig_cmd(struct l2cap_conn *conn, 5740 5765 struct l2cap_cmd_hdr *cmd, u16 cmd_len, 5741 5766 u8 *data) ··· 5780 5755 5781 5756 switch (cmd->code) { 5782 5757 case L2CAP_COMMAND_REJ: 5758 + l2cap_le_command_rej(conn, cmd, cmd_len, data); 5783 5759 break; 5784 5760 5785 5761 case L2CAP_CONN_PARAM_UPDATE_REQ: