bridge: Check for null ofproto_controller_info pointer.
authorAndrew Evans <aevans@nicira.com>
Tue, 25 Jan 2011 01:01:53 +0000 (17:01 -0800)
committerAndrew Evans <aevans@nicira.com>
Tue, 25 Jan 2011 01:12:47 +0000 (17:12 -0800)
This fixes a bug I introduced in commit bffc0589.

Reported-by: Bryan Fulton <bryan@nicira.com>
Bug #4474.

vswitchd/bridge.c

index 1065d6e..5339154 100644 (file)
@@ -1342,13 +1342,20 @@ bridge_refresh_controller_status(const struct bridge *br)
     ofproto_get_ofproto_controller_info(br->ofproto, &info);
 
     OVSREC_CONTROLLER_FOR_EACH(cfg, idl) {
-        struct ofproto_controller_info *cinfo = shash_find_data(&info, cfg->target);
-
-        ovsrec_controller_set_is_connected(cfg, cinfo->is_connected);
-        ovsrec_controller_set_role(cfg, nx_role_to_str(cinfo->role));
-        ovsrec_controller_set_status(cfg, (char **) cinfo->pairs.keys,
-                                     (char **) cinfo->pairs.values,
-                                     cinfo->pairs.n);
+        struct ofproto_controller_info *cinfo =
+            shash_find_data(&info, cfg->target);
+
+        if (cinfo) {
+            ovsrec_controller_set_is_connected(cfg, cinfo->is_connected);
+            ovsrec_controller_set_role(cfg, nx_role_to_str(cinfo->role));
+            ovsrec_controller_set_status(cfg, (char **) cinfo->pairs.keys,
+                                         (char **) cinfo->pairs.values,
+                                         cinfo->pairs.n);
+        } else {
+            ovsrec_controller_set_is_connected(cfg, false);
+            ovsrec_controller_set_role(cfg, NULL);
+            ovsrec_controller_set_status(cfg, NULL, NULL, 0);
+        }
     }
 
     ofproto_free_ofproto_controller_info(&info);