[ovs-dev] [PATCH] ovn: Free default db befor exit.

Alex Wang alexw at nicira.com
Tue Aug 18 18:06:34 UTC 2015


Acked-by: Alex Wang <alexw at nicira.com>

On Tue, Aug 18, 2015 at 8:24 AM, Russell Bryant <rbryant at redhat.com> wrote:

> The static result of default_db() was malloc'd but not freed before
> exit.  Make the static result global and free it before exit.
>
> Signed-off-by: Russell Bryant <rbryant at redhat.com>
> ---
>  ovn/northd/ovn-northd.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
> index 554dba3..9d3d658 100644
> --- a/ovn/northd/ovn-northd.c
> +++ b/ovn/northd/ovn-northd.c
> @@ -1016,14 +1016,16 @@ ovnsb_db_changed(struct northd_context *ctx)
>      hmap_destroy(&lports_hmap);
>  }
>
> +
> +static char *default_db_;
> +
>  static const char *
>  default_db(void)
>  {
> -    static char *def;
> -    if (!def) {
> -        def = xasprintf("unix:%s/db.sock", ovs_rundir());
> +    if (!default_db_) {
> +        default_db_ = xasprintf("unix:%s/db.sock", ovs_rundir());
>      }
> -    return def;
> +    return default_db_;
>  }
>
>  static void
> @@ -1322,6 +1324,8 @@ main(int argc, char *argv[])
>      ovsdb_idl_destroy(ovnnb_idl);
>      service_stop();
>
> +    free(default_db_);
> +
>      exit(res);
>  }
>
> --
> 2.4.3
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>



More information about the dev mailing list