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

Han Zhou hzhou at ovn.org
Wed Jan 22 21:47:58 UTC 2020


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 at ovn.org>
Signed-off-by: Han Zhou <hzhou at ovn.org>
---
 ovn/controller/ovn-controller.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

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. */
-- 
2.1.0



More information about the dev mailing list