diff mbox series

[ovs-dev,branch-2.12,1/2] ovn-controller.c: Fix possible NULL pointer dereference.

Message ID 1579729679-37362-1-git-send-email-hzhou@ovn.org
State Accepted
Commit e92a274a8ca8636a064626d01dba15fa9d3a75fd
Headers show
Series [ovs-dev,branch-2.12,1/2] ovn-controller.c: Fix possible NULL pointer dereference. | expand

Commit Message

Han Zhou Jan. 22, 2020, 9:47 p.m. UTC
In function update_sb_db(), it tries to access cfg->external_ids
outside of the "if (cfg)" block. This patch fixes it.

Acked-by: Numan Siddique <numans@ovn.org>
Signed-off-by: Han Zhou <hzhou@ovn.org>
---
 ovn/controller/ovn-controller.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c
index e2fce92..eb885fc 100644
--- a/ovn/controller/ovn-controller.c
+++ b/ovn/controller/ovn-controller.c
@@ -430,12 +430,12 @@  static void
 update_sb_db(struct ovsdb_idl *ovs_idl, struct ovsdb_idl *ovnsb_idl)
 {
     const struct ovsrec_open_vswitch *cfg = ovsrec_open_vswitch_first(ovs_idl);
+    if (!cfg) {
+        return;
+    }
 
     /* Set remote based on user configuration. */
-    const char *remote = NULL;
-    if (cfg) {
-        remote = smap_get(&cfg->external_ids, "ovn-remote");
-    }
+    const char *remote = smap_get(&cfg->external_ids, "ovn-remote");
     ovsdb_idl_set_remote(ovnsb_idl, remote, true);
 
     /* Set probe interval, based on user configuration and the remote. */