mesh: Check subnet existence in heartbeat_send
Check that the assigned subnet hasn't been removed in heartbeat_send to
avoid potential NULL defererence in transport's ctl_send.
this is port of
@@ -87,8 +87,10 @@ static int heartbeat_send(const struct bt_mesh_send_cb *cb, void *cb_data)
.xmit = bt_mesh_net_transmit_get(),
};
- /* Do nothing if heartbeat publication is not enabled */
- if (pub.dst == BT_MESH_ADDR_UNASSIGNED) {
+ /* Do nothing if heartbeat publication is not enabled or the subnet is
+ * removed.
+ */
+ if (!tx.sub || pub.dst == BT_MESH_ADDR_UNASSIGNED) {
return 0U;
}
