]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/5.0.15/bluetooth-fix-not-initializing-l2cap-tx_credits.patch
Linux 4.19.42
[thirdparty/kernel/stable-queue.git] / releases / 5.0.15 / bluetooth-fix-not-initializing-l2cap-tx_credits.patch
1 From ba8f5289f706aed94cc95b15cc5b89e22062f61f Mon Sep 17 00:00:00 2001
2 From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
3 Date: Thu, 14 Mar 2019 15:43:37 +0200
4 Subject: Bluetooth: Fix not initializing L2CAP tx_credits
5
6 From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
7
8 commit ba8f5289f706aed94cc95b15cc5b89e22062f61f upstream.
9
10 l2cap_le_flowctl_init was reseting the tx_credits which works only for
11 outgoing connection since that set the tx_credits on the response, for
12 incoming connections that was not the case which leaves the channel
13 without any credits causing it to be suspended.
14
15 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
16 Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
17 Cc: stable@vger.kernel.org # 4.20+
18 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
19
20 ---
21 net/bluetooth/l2cap_core.c | 9 ++++-----
22 1 file changed, 4 insertions(+), 5 deletions(-)
23
24 --- a/net/bluetooth/l2cap_core.c
25 +++ b/net/bluetooth/l2cap_core.c
26 @@ -510,12 +510,12 @@ void l2cap_chan_set_defaults(struct l2ca
27 }
28 EXPORT_SYMBOL_GPL(l2cap_chan_set_defaults);
29
30 -static void l2cap_le_flowctl_init(struct l2cap_chan *chan)
31 +static void l2cap_le_flowctl_init(struct l2cap_chan *chan, u16 tx_credits)
32 {
33 chan->sdu = NULL;
34 chan->sdu_last_frag = NULL;
35 chan->sdu_len = 0;
36 - chan->tx_credits = 0;
37 + chan->tx_credits = tx_credits;
38 /* Derive MPS from connection MTU to stop HCI fragmentation */
39 chan->mps = min_t(u16, chan->imtu, chan->conn->mtu - L2CAP_HDR_SIZE);
40 /* Give enough credits for a full packet */
41 @@ -1281,7 +1281,7 @@ static void l2cap_le_connect(struct l2ca
42 if (test_and_set_bit(FLAG_LE_CONN_REQ_SENT, &chan->flags))
43 return;
44
45 - l2cap_le_flowctl_init(chan);
46 + l2cap_le_flowctl_init(chan, 0);
47
48 req.psm = chan->psm;
49 req.scid = cpu_to_le16(chan->scid);
50 @@ -5531,11 +5531,10 @@ static int l2cap_le_connect_req(struct l
51 chan->dcid = scid;
52 chan->omtu = mtu;
53 chan->remote_mps = mps;
54 - chan->tx_credits = __le16_to_cpu(req->credits);
55
56 __l2cap_chan_add(conn, chan);
57
58 - l2cap_le_flowctl_init(chan);
59 + l2cap_le_flowctl_init(chan, __le16_to_cpu(req->credits));
60
61 dcid = chan->scid;
62 credits = chan->rx_credits;