ofproto-dpif: Add check in rstp_run.
authorDaniele Venturino <daniele.venturino@m3s.it>
Wed, 30 Sep 2015 08:49:52 +0000 (10:49 +0200)
committerJarno Rajahalme <jrajahalme@nicira.com>
Mon, 12 Oct 2015 18:34:51 +0000 (11:34 -0700)
Check if old_root_aux and new_root_aux are null before invoking
bundle_move() on them.

Signed-off-by: Daniele Venturino <daniele.venturino@m3s.it>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
lib/rstp.c
ofproto/ofproto-dpif.c

index a057c60..c1d5e7e 100644 (file)
@@ -280,6 +280,8 @@ rstp_create(const char *name, rstp_identifier bridge_address,
     rstp->aux = aux;
     rstp->changes = false;
     rstp->begin = true;
+    rstp->old_root_aux = NULL;
+    rstp->new_root_aux = NULL;
 
     ovs_refcount_init(&rstp->ref_cnt);
 
index ef1ad18..7b46f0f 100644 (file)
@@ -2296,9 +2296,14 @@ rstp_run(struct ofproto_dpif *ofproto)
         }
 
         if (rstp_shift_root_learned_address(ofproto->rstp)) {
-            bundle_move(((struct ofport_dpif *)rstp_get_old_root_aux(ofproto->rstp))->bundle,
-                        ((struct ofport_dpif *)rstp_get_new_root_aux(ofproto->rstp))->bundle);
-            rstp_reset_root_changed(ofproto->rstp);
+            struct ofport_dpif *old_root_aux =
+                (struct ofport_dpif *)rstp_get_old_root_aux(ofproto->rstp);
+            struct ofport_dpif *new_root_aux =
+                (struct ofport_dpif *)rstp_get_new_root_aux(ofproto->rstp);
+            if (old_root_aux != NULL && new_root_aux != NULL) {
+                bundle_move(old_root_aux->bundle, new_root_aux->bundle);
+                rstp_reset_root_changed(ofproto->rstp);
+            }
         }
     }
 }