]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pimd: Cleanup termination to avoid possible null ptr deref
authorDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 31 Mar 2017 20:56:26 +0000 (16:56 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 31 Mar 2017 20:56:26 +0000 (16:56 -0400)
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>
pimd/pimd.c

index 72fe0e7046cff0d79e2a875334162bdfc15fec4f..bdbd251e209722581d7f44539524863db9404312 100644 (file)
@@ -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);
 }