diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-03-31 22:56:26 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-03-31 22:56:26 +0200 |
commit | 6ca7dd9045d720374a490e21b13393095fd4a9b0 (patch) | |
tree | 4aaf6e2c955f7b6c646f16a5d2e053074d25b394 /pimd | |
parent | pimd: Fix incorrect indentation (diff) | |
download | frr-6ca7dd9045d720374a490e21b13393095fd4a9b0.tar.xz frr-6ca7dd9045d720374a490e21b13393095fd4a9b0.zip |
pimd: Cleanup termination to avoid possible null ptr deref
When terminating pim, there existed( albeit small ) the chance
to cause a crash. Cleanup the termination to not have
that chance.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'pimd')
-rw-r--r-- | pimd/pimd.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/pimd/pimd.c b/pimd/pimd.c index 72fe0e704..bdbd251e2 100644 --- a/pimd/pimd.c +++ b/pimd/pimd.c @@ -108,8 +108,14 @@ pim_vrf_enable (struct vrf *vrf) { pimg = pim_instance_init (VRF_DEFAULT, AFI_IP); if (pimg == NULL) - zlog_err ("%s %s: pim class init failure ", __FILE__, - __PRETTY_FUNCTION__); + { + zlog_err ("%s %s: pim class init failure ", __FILE__, + __PRETTY_FUNCTION__); + /* + * We will crash and burn otherwise + */ + exit(1); + } } return 0; } @@ -194,12 +200,18 @@ static void pim_instance_terminate (void) { /* Traverse and cleanup rpf_hash */ - if (pimg && pimg->rpf_hash) + if (pimg->rpf_hash) { hash_clean (pimg->rpf_hash, (void *) pim_rp_list_hash_clean); hash_free (pimg->rpf_hash); + pimg->rpf_hash = NULL; + } + + if (pimg->ssm_info) + { + pim_ssm_terminate (pimg->ssm_info); + pimg->ssm_info = NULL; } - pim_ssm_terminate (pimg->ssm_info); XFREE (MTYPE_PIM_PIM_INSTANCE, pimg); } |