Skip to content

Commit 6c7a387

Browse files
Vudentzjhedberg
authored andcommitted
Bluetooth: ATT: Fix handling to EATT channels
EATT channels use bt_l2cap_chan_send which does return the number of bytes sent on success not 0 as bt_l2cap_send. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
1 parent f72aef1 commit 6c7a387

File tree

1 file changed

+12
-2
lines changed
  • subsys/bluetooth/host

1 file changed

+12
-2
lines changed

subsys/bluetooth/host/att.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ static int chan_send(struct bt_att_chan *chan, struct net_buf *buf,
154154

155155
if (IS_ENABLED(CONFIG_BT_EATT) &&
156156
atomic_test_bit(chan->flags, ATT_ENHANCED)) {
157+
int err;
158+
157159
/* Check if sent is pending already, if it does it cannot be
158160
* modified so the operation will need to be queued.
159161
*/
@@ -174,7 +176,15 @@ static int chan_send(struct bt_att_chan *chan, struct net_buf *buf,
174176
return -EAGAIN;
175177
}
176178

177-
return bt_l2cap_chan_send(&chan->chan.chan, buf);
179+
/* bt_l2cap_chan_send does actually return the number of bytes
180+
* that could be sent immediatelly.
181+
*/
182+
err = bt_l2cap_chan_send(&chan->chan.chan, buf);
183+
if (err < 0) {
184+
return err;
185+
}
186+
187+
return 0;
178188
}
179189

180190
if (hdr->code == BT_ATT_OP_SIGNED_WRITE_CMD) {
@@ -233,7 +243,7 @@ static int chan_req_send(struct bt_att_chan *chan, struct bt_att_req *req)
233243

234244
/* Keep a reference for resending in case of an error */
235245
err = chan_send(chan, net_buf_ref(req->buf), NULL);
236-
if (err < 0) {
246+
if (err) {
237247
net_buf_unref(req->buf);
238248
chan->req = NULL;
239249
}

0 commit comments

Comments
 (0)