vswitchd: Avoid segfault when creating a bridge fails.
authorBen Pfaff <blp@nicira.com>
Thu, 3 Dec 2009 23:14:56 +0000 (15:14 -0800)
committerBen Pfaff <blp@nicira.com>
Thu, 3 Dec 2009 23:14:56 +0000 (15:14 -0800)
bridge_create() can return a null pointer if creating the bridge fails, so
check for that and don't dereference it in that case.

Thank to Jeremy Stribling for reporting the problem.

vswitchd/bridge.c

index 3028766cd93771ae96bd48b35897145f9b641a3b..581af96a26c2f52fce7940ee64944009e16b6499 100644 (file)
@@ -562,7 +562,9 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg)
         const struct ovsrec_bridge *br_cfg = node->data;
         if (!shash_find_data(&old_br, br_name)) {
             br = bridge_create(br_name);
-            br->cfg = br_cfg;
+            if (br) {
+                br->cfg = br_cfg;
+            }
         }
     }
     shash_destroy(&old_br);