vty: Avoid crash in tbf_print_vty_info with null ptr ctrg

Previous code did use a ctrg based on MS being EGPRS capable or not.
However, an MS being EGPRS capable doesn't mean necessarily that all its
TBFs are EGPRS, since we may known about the capability after we already
created some previous TBF, so it was not ugpraded. Hence, we were
sometimes accessing the wrong NULL ctrg.
Let's simply check for non NULL ctrg when deciding what to print.

"""
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7561ea6 in vty_out_rate_ctr_group (vty=vty@entry=0x897850, prefix=prefix@entry=0x4482cd " ", ctrg=0x0) at utils.c:82
82    utils.c: No such file or directory.
(gdb) bt
 #0  0x00007ffff7561ea6 in vty_out_rate_ctr_group (vty=vty@entry=0x897850, prefix=prefix@entry=0x4482cd " ", ctrg=0x0) at utils.c:82
 #1  0x000000000041437b in tbf_print_vty_info (vty=vty@entry=0x897850, tbf=0x3fb61f0) at pcu_vty_functions.cpp:98
 #2  0x0000000000414acc in pcu_vty_show_tbf_all (vty=vty@entry=0x897850, bts=bts@entry=0x7be650, flags=4294967295) at pcu_vty_functions.cpp:127
 #3  0x000000000041206f in show_tbf (self=<optimized out>, vty=0x897850, argc=<optimized out>, argv=0x7fffffffe040) at pcu_vty.c:1150
 #4  0x00007ffff755d167 in cmd_execute_command_real (vline=vline@entry=0x7bc300, vty=vty@entry=0x897850, cmd=<optimized out>) at command.c:2604
"""

Related: SYS#5689
Change-Id: I3979bfc12dd3b9a53b34b284537f271c356a3024
This commit is contained in:
Pau Espin 2021-11-05 13:36:49 +01:00
parent 7ce56d7c64
commit 43fc4a8690
1 changed files with 4 additions and 6 deletions

View File

@ -79,11 +79,10 @@ static void tbf_print_vty_info(struct vty *vty, struct gprs_rlcmac_tbf *tbf)
ul_tbf->window_size(), win->v_q(), win->v_r());
vty_out(vty, "%s", VTY_NEWLINE);
vty_out(vty, " TBF Statistics:%s", VTY_NEWLINE);
if (GPRS == ms_mode(tbf->ms())) {
if (ul_tbf->m_ul_gprs_ctrs)
vty_out_rate_ctr_group(vty, " ", ul_tbf->m_ul_gprs_ctrs);
} else {
if (ul_tbf->m_ul_egprs_ctrs)
vty_out_rate_ctr_group(vty, " ", ul_tbf->m_ul_egprs_ctrs);
}
}
if (dl_tbf) {
gprs_rlc_dl_window *win = static_cast<gprs_rlc_dl_window *>(dl_tbf->window());
@ -92,11 +91,10 @@ static void tbf_print_vty_info(struct vty *vty, struct gprs_rlcmac_tbf *tbf)
win->window_stalled() ? " STALLED" : "");
vty_out(vty, "%s", VTY_NEWLINE);
vty_out_rate_ctr_group(vty, " ", tbf->m_ctrs);
if (GPRS == ms_mode(tbf->ms())) {
if (dl_tbf->m_dl_gprs_ctrs)
vty_out_rate_ctr_group(vty, " ", dl_tbf->m_dl_gprs_ctrs);
} else {
if (dl_tbf->m_dl_egprs_ctrs)
vty_out_rate_ctr_group(vty, " ", dl_tbf->m_dl_egprs_ctrs);
}
}
vty_out(vty, "%s%s", VTY_NEWLINE, VTY_NEWLINE);
}