Bluetooth: L2CAP: Unref buffer after calling recv callback

This simplify the handling quite a bit while the application can still
prevent the buffer to be freed by referencing it if necessary.

Change-Id: I5ed0e96e8d9e349b79ba31ba9568af61181e1065
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
Luiz Augusto von Dentz 2015-11-02 16:11:15 +02:00 committed by Anas Nashif
commit 5bd4324ae2
5 changed files with 10 additions and 22 deletions

View file

@ -1478,7 +1478,7 @@ static void bt_att_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
if (buf->len < sizeof(*hdr)) {
BT_ERR("Too small ATT PDU received\n");
goto done;
return;
}
BT_DBG("Received ATT code 0x%02x len %u\n", hdr->code, buf->len);
@ -1503,16 +1503,13 @@ static void bt_att_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
/* Commands don't have response */
if ((hdr->code & BT_ATT_OP_CMD_FLAG)) {
goto done;
return;
}
if (err) {
BT_DBG("ATT error 0x%02x", err);
send_err_rsp(chan->conn, hdr->code, 0, err);
}
done:
net_buf_unref(buf);
}
static struct bt_att *att_chan_get(struct bt_conn *conn)