Commit 2520d111 authored by Michael Cook's avatar Michael Cook

Fix shutdown crashes

In phy_free_lte_eNB in lte_init.c, the lte-uesoftmodem would
crash during shutdown because it was dereferencing null pointers.
This commit adds checks to avoid that.
parent 8b2b78e4
...@@ -507,12 +507,14 @@ void phy_free_lte_eNB(PHY_VARS_eNB *eNB) { ...@@ -507,12 +507,14 @@ void phy_free_lte_eNB(PHY_VARS_eNB *eNB) {
LTE_eNB_PRACH *const prach_vars_br = &eNB->prach_vars_br; LTE_eNB_PRACH *const prach_vars_br = &eNB->prach_vars_br;
int i, UE_id; int i, UE_id;
for (i = 0; i < NB_ANTENNA_PORTS_ENB; i++) { if (common_vars->txdataF) {
if (i < fp->nb_antenna_ports_eNB || i == 5) { for (i = 0; i < NB_ANTENNA_PORTS_ENB; i++) {
free_and_zero(common_vars->txdataF[i]); if (i < fp->nb_antenna_ports_eNB || i == 5) {
/* rxdataF[i] is not allocated -> don't free */ free_and_zero(common_vars->txdataF[i]);
}
} }
} }
/* rxdataF[i] is not allocated -> don't free */
free_and_zero(common_vars->txdataF); free_and_zero(common_vars->txdataF);
free_and_zero(common_vars->rxdataF); free_and_zero(common_vars->rxdataF);
...@@ -520,8 +522,10 @@ void phy_free_lte_eNB(PHY_VARS_eNB *eNB) { ...@@ -520,8 +522,10 @@ void phy_free_lte_eNB(PHY_VARS_eNB *eNB) {
// Channel estimates for SRS // Channel estimates for SRS
for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) {
for (i=0; i<64; i++) { for (i=0; i<64; i++) {
free_and_zero(srs_vars[UE_id].srs_ch_estimates[i]); if (srs_vars[UE_id].srs_ch_estimates)
free_and_zero(srs_vars[UE_id].srs_ch_estimates_time[i]); free_and_zero(srs_vars[UE_id].srs_ch_estimates[i]);
if (srs_vars[UE_id].srs_ch_estimates_time)
free_and_zero(srs_vars[UE_id].srs_ch_estimates_time[i]);
} }
free_and_zero(srs_vars[UE_id].srs_ch_estimates); free_and_zero(srs_vars[UE_id].srs_ch_estimates);
...@@ -534,41 +538,57 @@ void phy_free_lte_eNB(PHY_VARS_eNB *eNB) { ...@@ -534,41 +538,57 @@ void phy_free_lte_eNB(PHY_VARS_eNB *eNB) {
free_and_zero(prach_vars->prachF); free_and_zero(prach_vars->prachF);
for (i = 0; i < 64; i++) free_and_zero(prach_vars->prach_ifft[0][i]); if (prach_vars->prach_ifft[0]) {
for (i = 0; i < 64; i++) {
free_and_zero(prach_vars->prach_ifft[0]); free_and_zero(prach_vars->prach_ifft[0][i]);
}
free_and_zero(prach_vars->prach_ifft[0]);
}
for (int ce_level = 0; ce_level < 4; ce_level++) { for (int ce_level = 0; ce_level < 4; ce_level++) {
for (i = 0; i < 64; i++) free_and_zero(prach_vars_br->prach_ifft[ce_level][i]); if (prach_vars_br->prach_ifft[ce_level]) {
for (i = 0; i < 64; i++) {
free_and_zero(prach_vars_br->prach_ifft[ce_level]); free_and_zero(prach_vars_br->prach_ifft[ce_level][i]);
}
free_and_zero(prach_vars_br->prach_ifft[ce_level]);
}
free_and_zero(prach_vars->rxsigF[ce_level]); free_and_zero(prach_vars->rxsigF[ce_level]);
} }
free_and_zero(prach_vars_br->prachF); free_and_zero(prach_vars_br->prachF);
free_and_zero(prach_vars->rxsigF[0]); free_and_zero(prach_vars->rxsigF[0]);
for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) { if (pusch_vars[UE_id]) {
for (i = 0; i < 2; i++) { LTE_eNB_PUSCH *pv = pusch_vars[UE_id];
free_and_zero(pusch_vars[UE_id]->rxdataF_ext[i]); for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) {
free_and_zero(pusch_vars[UE_id]->rxdataF_ext2[i]); for (i = 0; i < 2; i++) {
free_and_zero(pusch_vars[UE_id]->drs_ch_estimates[i]); if (pv->rxdataF_ext)
free_and_zero(pusch_vars[UE_id]->drs_ch_estimates_time[i]); free_and_zero(pv->rxdataF_ext[i]);
free_and_zero(pusch_vars[UE_id]->rxdataF_comp[i]); if (pv->rxdataF_ext2)
free_and_zero(pusch_vars[UE_id]->ul_ch_mag[i]); free_and_zero(pv->rxdataF_ext2[i]);
free_and_zero(pusch_vars[UE_id]->ul_ch_magb[i]); if (pv->drs_ch_estimates)
} free_and_zero(pv->drs_ch_estimates[i]);
if (pv->drs_ch_estimates_time)
free_and_zero(pv->drs_ch_estimates_time[i]);
if (pv->rxdataF_comp)
free_and_zero(pv->rxdataF_comp[i]);
if (pv->ul_ch_mag)
free_and_zero(pv->ul_ch_mag[i]);
if (pv->ul_ch_magb)
free_and_zero(pv->ul_ch_magb[i]);
}
free_and_zero(pusch_vars[UE_id]->rxdataF_ext); free_and_zero(pv->rxdataF_ext);
free_and_zero(pusch_vars[UE_id]->rxdataF_ext2); free_and_zero(pv->rxdataF_ext2);
free_and_zero(pusch_vars[UE_id]->drs_ch_estimates); free_and_zero(pv->drs_ch_estimates);
free_and_zero(pusch_vars[UE_id]->drs_ch_estimates_time); free_and_zero(pv->drs_ch_estimates_time);
free_and_zero(pusch_vars[UE_id]->rxdataF_comp); free_and_zero(pv->rxdataF_comp);
free_and_zero(pusch_vars[UE_id]->ul_ch_mag); free_and_zero(pv->ul_ch_mag);
free_and_zero(pusch_vars[UE_id]->ul_ch_magb); free_and_zero(pv->ul_ch_magb);
free_and_zero(pusch_vars[UE_id]->llr); free_and_zero(pv->llr);
free_and_zero(pusch_vars[UE_id]); free_and_zero(pv);
} //UE_id }
}
for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) eNB->UE_stats_ptr[UE_id] = NULL; for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) eNB->UE_stats_ptr[UE_id] = NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment