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

Mark Michelson mmichels at redhat.com
Tue Jan 14 21:24:08 UTC 2020


Hi Han.

This patch introduces a small behavior change in the case where cfg is 
NULL. In the earlier version, we would always set the probe interval on 
the southbound database. With this version of the patch, we exit early 
when cfg is NULL and do not set the probe interval.

On 1/13/20 5:52 PM, Han Zhou wrote:
> In function update_sb_db(), it tries to access cfg->external_ids
> outside of the "if (cfg)" block. This patch fixes it.
> 
> Signed-off-by: Han Zhou <hzhou at ovn.org>
> ---
>   controller/ovn-controller.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c
> index 17744d4..3d843f7 100644
> --- a/controller/ovn-controller.c
> +++ b/controller/ovn-controller.c
> @@ -431,12 +431,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. */
> 



More information about the dev mailing list