mirror of https://github.com/PentHertz/srsLTE.git
nr,gnb,rrc: check for nullptr return of byte buffer pool.
This commit is contained in:
parent
b35584ae70
commit
35507850d3
|
@ -162,7 +162,22 @@ private:
|
||||||
|
|
||||||
// Helper to create PDU from RRC message
|
// Helper to create PDU from RRC message
|
||||||
template <class T>
|
template <class T>
|
||||||
srsran::unique_byte_buffer_t pack_into_pdu(const T& msg);
|
srsran::unique_byte_buffer_t pack_into_pdu(const T& msg)
|
||||||
|
{
|
||||||
|
// Allocate a new PDU buffer and pack the
|
||||||
|
srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer();
|
||||||
|
if (pdu == nullptr) {
|
||||||
|
logger.error("Couldn't allocate PDU in %s().", __FUNCTION__);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
asn1::bit_ref bref(pdu->msg, pdu->get_tailroom());
|
||||||
|
if (msg.pack(bref) == asn1::SRSASN_ERROR_ENCODE_FAIL) {
|
||||||
|
logger.error("Failed to pack message. Discarding it.");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
pdu->N_bytes = bref.distance_bytes();
|
||||||
|
return pdu;
|
||||||
|
}
|
||||||
void log_rx_pdu_fail(uint16_t rnti,
|
void log_rx_pdu_fail(uint16_t rnti,
|
||||||
uint32_t lcid,
|
uint32_t lcid,
|
||||||
srsran::const_byte_span pdu,
|
srsran::const_byte_span pdu,
|
||||||
|
|
|
@ -648,25 +648,4 @@ void rrc_nr::sgnb_release_request(uint16_t nr_rnti)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
|
||||||
srsran::unique_byte_buffer_t rrc_nr::pack_into_pdu(const T& msg)
|
|
||||||
{
|
|
||||||
// Allocate a new PDU buffer and pack the
|
|
||||||
srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer();
|
|
||||||
if (pdu == nullptr) {
|
|
||||||
logger.error("Couldn't allocate PDU in %s().", __FUNCTION__);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
asn1::bit_ref bref(pdu->msg, pdu->get_tailroom());
|
|
||||||
if (msg.pack(bref) == asn1::SRSASN_ERROR_ENCODE_FAIL) {
|
|
||||||
logger.error("Failed to pack message. Discarding it.");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
pdu->N_bytes = bref.distance_bytes();
|
|
||||||
return pdu;
|
|
||||||
}
|
|
||||||
|
|
||||||
template srsran::unique_byte_buffer_t rrc_nr::pack_into_pdu<dl_ccch_msg_s>(const dl_ccch_msg_s& msg);
|
|
||||||
template srsran::unique_byte_buffer_t rrc_nr::pack_into_pdu<dl_dcch_msg_s>(const dl_dcch_msg_s& msg);
|
|
||||||
|
|
||||||
} // namespace srsenb
|
} // namespace srsenb
|
||||||
|
|
|
@ -926,19 +926,14 @@ void rrc_nr::ue::send_rrc_setup()
|
||||||
asn1::rrc_nr::cell_group_cfg_s master_cell_group = *parent->cell_ctxt->master_cell_group;
|
asn1::rrc_nr::cell_group_cfg_s master_cell_group = *parent->cell_ctxt->master_cell_group;
|
||||||
// - Derive master cell group config bearers
|
// - Derive master cell group config bearers
|
||||||
fill_cellgroup_with_radio_bearer_cfg(parent->cfg, setup_ies.radio_bearer_cfg, master_cell_group);
|
fill_cellgroup_with_radio_bearer_cfg(parent->cfg, setup_ies.radio_bearer_cfg, master_cell_group);
|
||||||
{
|
// - Pack masterCellGroup into container
|
||||||
srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer();
|
srsran::unique_byte_buffer_t pdu = parent->pack_into_pdu(master_cell_group);
|
||||||
asn1::bit_ref bref{pdu->data(), pdu->get_tailroom()};
|
if (pdu == nullptr) {
|
||||||
if (master_cell_group.pack(bref) != SRSRAN_SUCCESS) {
|
|
||||||
logger.error("Failed to pack master cell group");
|
|
||||||
send_rrc_reject(max_wait_time_secs);
|
send_rrc_reject(max_wait_time_secs);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pdu->N_bytes = bref.distance_bytes();
|
|
||||||
|
|
||||||
setup_ies.master_cell_group.resize(pdu->N_bytes);
|
setup_ies.master_cell_group.resize(pdu->N_bytes);
|
||||||
memcpy(setup_ies.master_cell_group.data(), pdu->data(), pdu->N_bytes);
|
memcpy(setup_ies.master_cell_group.data(), pdu->data(), pdu->N_bytes);
|
||||||
}
|
|
||||||
if (logger.debug.enabled()) {
|
if (logger.debug.enabled()) {
|
||||||
asn1::json_writer js;
|
asn1::json_writer js;
|
||||||
master_cell_group.to_json(js);
|
master_cell_group.to_json(js);
|
||||||
|
@ -1007,23 +1002,19 @@ void rrc_nr::ue::send_rrc_reconfiguration()
|
||||||
ies.non_crit_ext_present = true;
|
ies.non_crit_ext_present = true;
|
||||||
ies.non_crit_ext.master_cell_group_present = true;
|
ies.non_crit_ext.master_cell_group_present = true;
|
||||||
|
|
||||||
// masterCellGroup
|
// Fill masterCellGroup
|
||||||
asn1::rrc_nr::cell_group_cfg_s master_cell_group;
|
cell_group_cfg_s master_cell_group;
|
||||||
master_cell_group.cell_group_id = 0;
|
master_cell_group.cell_group_id = 0;
|
||||||
fill_cellgroup_with_radio_bearer_cfg(parent->cfg, ies.radio_bearer_cfg, master_cell_group);
|
fill_cellgroup_with_radio_bearer_cfg(parent->cfg, ies.radio_bearer_cfg, master_cell_group);
|
||||||
{
|
|
||||||
srsran::unique_byte_buffer_t pdu = srsran::make_byte_buffer();
|
// Pack masterCellGroup into container
|
||||||
asn1::bit_ref bref{pdu->data(), pdu->get_tailroom()};
|
srsran::unique_byte_buffer_t pdu = parent->pack_into_pdu(master_cell_group);
|
||||||
if (master_cell_group.pack(bref) != SRSRAN_SUCCESS) {
|
if (pdu == nullptr) {
|
||||||
logger.error("Failed to pack master cell group");
|
// TODO: Handle
|
||||||
// TODO: handle
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pdu->N_bytes = bref.distance_bytes();
|
|
||||||
|
|
||||||
ies.non_crit_ext.master_cell_group.resize(pdu->N_bytes);
|
ies.non_crit_ext.master_cell_group.resize(pdu->N_bytes);
|
||||||
memcpy(ies.non_crit_ext.master_cell_group.data(), pdu->data(), pdu->N_bytes);
|
memcpy(ies.non_crit_ext.master_cell_group.data(), pdu->data(), pdu->N_bytes);
|
||||||
}
|
|
||||||
// TODO: pass stored NAS PDU
|
// TODO: pass stored NAS PDU
|
||||||
|
|
||||||
// Update lower layers
|
// Update lower layers
|
||||||
|
@ -1070,8 +1061,8 @@ void rrc_nr::ue::establish_eps_bearer(uint32_t pdu_session_id, srsran::const_byt
|
||||||
// Add SRB2, if not yet added
|
// Add SRB2, if not yet added
|
||||||
if (radio_bearer_cfg.srb_to_add_mod_list.size() <= 1) {
|
if (radio_bearer_cfg.srb_to_add_mod_list.size() <= 1) {
|
||||||
next_radio_bearer_cfg.srb_to_add_mod_list_present = true;
|
next_radio_bearer_cfg.srb_to_add_mod_list_present = true;
|
||||||
next_radio_bearer_cfg.srb_to_add_mod_list.resize(1);
|
next_radio_bearer_cfg.srb_to_add_mod_list.push_back(srb_to_add_mod_s{});
|
||||||
next_radio_bearer_cfg.srb_to_add_mod_list[0].srb_id = 2;
|
next_radio_bearer_cfg.srb_to_add_mod_list.back().srb_id = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
drb_to_add_mod_s drb;
|
drb_to_add_mod_s drb;
|
||||||
|
|
Loading…
Reference in New Issue