nimble/hs: Fix data fragmentation

This fix following issue when there is no memory in the
os_msys_init_1_mempool:

0  ble_hs_hci_acl_hdr_prepend (pb_flag=0 '\000', handle=<optimized out>, om=0x0)
    at repos/apache-mynewt-nimble/nimble/host/src/ble_hs_hci.c:415
1  ble_hs_hci_acl_tx_now (conn=conn@entry=0x2000ab14 <ble_hs_conn_elem_mem>,
    om=om@entry=0x20004e9c <os_main_stack+3756>)
    at repos/apache-mynewt-nimble/nimble/host/src/ble_hs_hci.c:466
2  0x00038f80 in ble_hs_hci_acl_tx (
    conn=conn@entry=0x2000ab14 <ble_hs_conn_elem_mem>,
    om=om@entry=0x20004e9c <os_main_stack+3756>)
    at repos/apache-mynewt-nimble/nimble/host/src/ble_hs_hci.c:536
3  0x0003a404 in ble_l2cap_tx (conn=0x2000ab14 <ble_hs_conn_elem_mem>,
    chan=<optimized out>, txom=<optimized out>,
    txom@entry=0x200058a8 <os_msys_init_1_data+2128>)
    at repos/apache-mynewt-nimble/nimble/host/src/ble_l2cap.c:402
4  0x0003445a in ble_att_tx (conn_handle=conn_handle@entry=1,
    txom=0x200058a8 <os_msys_init_1_data+2128>)
    at repos/apache-mynewt-nimble/nimble/host/src/ble_att_cmd.c:76
5  0x00034372 in ble_att_clt_tx_notify (conn_handle=conn_handle@entry=1,
    handle=handle@entry=14, txom=txom@entry=0x20005778 <os_msys_init_1_data+1824>)
    at repos/apache-mynewt-nimble/nimble/host/src/ble_att_clt.c:962
6  0x00037020 in ble_gattc_notify_custom (conn_handle=conn_handle@entry=1,
    chr_val_handle=chr_val_handle@entry=14,
    txom=txom@entry=0x20005778 <os_msys_init_1_data+1824>)
    at repos/apache-mynewt-nimble/nimble/host/src/ble_gattc.c:4178
7  0x00032b5a in oc_send_buffer_gatt (m=0x20005778 <os_msys_init_1_data+1824>)
    at repos/apache-mynewt-core/net/oic/src/port/mynewt/ble_adaptor.c:529
8  0x0003046c in oc_buffer_tx (ev=<optimized out>)
    at repos/apache-mynewt-core/net/oic/src/api/oc_buffer.c:100
9  0x00022500 in main (argc=<optimized out>, argv=<optimized out>)
(gdb) p os_msys_init_1_mbuf_pool
$17 = {omp_databuf_len = 136, omp_pool = 0x20005d74 <os_msys_init_1_mempool>,
  omp_next = {stqe_next = 0x0}}
(gdb) p os_msys_init_1_mempool
$18 = {mp_block_size = 152, mp_num_blocks = 22, mp_num_free = 0, mp_min_free = 0,
  mp_flags = 0 '\000', mp_membuf_addr = 536891480, mp_list = {stqe_next = 0x0}, {
    slh_first = 0x0}, name = 0x4ea4d "msys_1"}
Collapse
This commit is contained in:
Łukasz Rymanowski
2019-03-21 12:21:25 +01:00
parent 87a77fd26b
commit 3ea16d5553
+4
View File
@@ -462,6 +462,10 @@ ble_hs_hci_acl_tx_now(struct ble_hs_conn *conn, struct os_mbuf **om)
while (txom != NULL && ble_hs_hci_avail_pkts > 0) {
frag = mem_split_frag(&txom, ble_hs_hci_max_acl_payload_sz(),
ble_hs_hci_frag_alloc, NULL);
if (frag == NULL) {
rc = BLE_HS_ENOMEM;
goto err;
}
frag = ble_hs_hci_acl_hdr_prepend(frag, conn->bhc_handle, pb);
if (frag == NULL) {