Skip to content

Commit

Permalink
mesh: Fix tx seg buffer with NULL pointer reference
Browse files Browse the repository at this point in the history
Bluetooth: Mesh: Fix tx seg buffer with NULL pointer reference

Fix tx seg buffer with NULL pointer reference if enable mesh friendly

this is port of zephyrproject-rtos/zephyr#27251
  • Loading branch information
KKopyscinski committed Nov 4, 2020
1 parent 05c1e27 commit 0ad84d0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions nimble/host/mesh/src/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,8 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct os_mbuf *sdu,
memcpy(buf, net_buf_simple_pull_mem(sdu, len), len);
BT_DBG("seg %u: %s", seg_o, bt_hex(buf, len));

tx->seg[seg_o] = buf;

if (IS_ENABLED(CONFIG_BT_MESH_FRIEND)) {
enum bt_mesh_friend_pdu_type type;

Expand All @@ -550,11 +552,10 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct os_mbuf *sdu,
* out through the Friend Queue.
*/
k_mem_slab_free(&segs, &buf);
continue;
tx->seg[seg_o] = NULL;
}
}

tx->seg[seg_o] = buf;
}

/* This can happen if segments only went into the Friend Queue */
Expand Down

0 comments on commit 0ad84d0

Please sign in to comment.