From 00a6b4c5ae9ff54d266c075eead897820118e6c7 Mon Sep 17 00:00:00 2001 From: Loic Poulain Date: Wed, 30 May 2018 12:01:30 +0200 Subject: [PATCH] usb: bluetooth: Fix assert due to unreserved headroom Bluetooth net buffers have 1-byte reserve, which can be used by HCI bus driver (uart, spi...) to set packet type (H4). This fixes assert when building hci_usb with CONFIG_NET_BUF_SIMPLE_LOG. Signed-off-by: Loic Poulain --- subsys/usb/class/bluetooth.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/subsys/usb/class/bluetooth.c b/subsys/usb/class/bluetooth.c index 6cdf561b82e..a5a5cc95a76 100644 --- a/subsys/usb/class/bluetooth.c +++ b/subsys/usb/class/bluetooth.c @@ -142,10 +142,11 @@ static void bluetooth_bulk_out_callback(u8_t ep, return; } - usb_read(ep, net_buf_add(buf, len), len, NULL); - + net_buf_reserve(buf, CONFIG_BT_HCI_RESERVE); bt_buf_set_type(buf, BT_BUF_ACL_OUT); + usb_read(ep, net_buf_add(buf, len), len, NULL); + net_buf_put(&tx_queue, buf); } @@ -167,6 +168,7 @@ static int bluetooth_class_handler(struct usb_setup_packet *setup, return -ENOMEM; } + net_buf_reserve(buf, CONFIG_BT_HCI_RESERVE); bt_buf_set_type(buf, BT_BUF_CMD); net_buf_add_mem(buf, *data, *len);