Bluetooth: Use assert when getting net buf with K_FOREVER
net_buf_alloc called with K_FOREVER should always return valid pointer. Returning NULL indicated kernel bug. Change-Id: I6c317de2d98723d0c1a0618e91490a2128f69f06 Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
This commit is contained in:
parent
46ed7974b3
commit
295e8e575c
3 changed files with 13 additions and 6 deletions
|
@ -14,6 +14,7 @@
|
|||
#include <misc/byteorder.h>
|
||||
#include <misc/util.h>
|
||||
#include <misc/stack.h>
|
||||
#include <misc/__assert.h>
|
||||
|
||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_CONN)
|
||||
#include <bluetooth/log.h>
|
||||
|
@ -1596,11 +1597,10 @@ struct net_buf *bt_conn_create_pdu(struct net_buf_pool *pool, size_t reserve)
|
|||
}
|
||||
|
||||
buf = net_buf_alloc(pool, K_FOREVER);
|
||||
if (buf) {
|
||||
reserve += sizeof(struct bt_hci_acl_hdr) +
|
||||
CONFIG_BLUETOOTH_HCI_RESERVE;
|
||||
net_buf_reserve(buf, reserve);
|
||||
}
|
||||
__ASSERT_NO_MSG(buf);
|
||||
|
||||
reserve += sizeof(struct bt_hci_acl_hdr) + CONFIG_BLUETOOTH_HCI_RESERVE;
|
||||
net_buf_reserve(buf, reserve);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <misc/util.h>
|
||||
#include <misc/byteorder.h>
|
||||
#include <misc/stack.h>
|
||||
#include <misc/__assert.h>
|
||||
#include <soc.h>
|
||||
|
||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_HCI_CORE)
|
||||
|
@ -151,6 +152,7 @@ struct net_buf *bt_hci_cmd_create(uint16_t opcode, uint8_t param_len)
|
|||
BT_DBG("opcode 0x%04x param_len %u", opcode, param_len);
|
||||
|
||||
buf = net_buf_alloc(&hci_cmd_pool, K_FOREVER);
|
||||
__ASSERT_NO_MSG(buf);
|
||||
|
||||
BT_DBG("buf %p", buf);
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <misc/byteorder.h>
|
||||
#include <misc/__assert.h>
|
||||
|
||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLUETOOTH_DEBUG_SDP)
|
||||
#include <bluetooth/log.h>
|
||||
|
@ -700,12 +701,16 @@ static int sdp_client_chan_connect(struct bt_sdp_client *session)
|
|||
static struct net_buf *sdp_client_alloc_buf(struct bt_l2cap_chan *chan)
|
||||
{
|
||||
struct bt_sdp_client *session = SDP_CLIENT_CHAN(chan);
|
||||
struct net_buf *buf;
|
||||
|
||||
BT_DBG("session %p chan %p", session, chan);
|
||||
|
||||
session->param = GET_PARAM(sys_slist_peek_head(&session->reqs));
|
||||
|
||||
return net_buf_alloc(session->param->pool, K_FOREVER);
|
||||
buf = net_buf_alloc(session->param->pool, K_FOREVER);
|
||||
__ASSERT_NO_MSG(buf);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
static void sdp_client_connected(struct bt_l2cap_chan *chan)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue