"dev" <[email protected]> wrote on 05/13/2016 05:26:10 PM:

> From: William Tu <[email protected]>
> To: [email protected]
> Date: 05/13/2016 05:26 PM
> Subject: [ovs-dev] [PATCH] ovn-nbctl: Fix memory leak reported by
Valgrind.
> Sent by: "dev" <[email protected]>
>
> Definitely lost is reported by test 2026: ovn -- 3 HVs, 1 LS, 3
lports/HV.
>   ds_put_char__ (dynamic-string.c:82)
>   ds_put_char (dynamic-string.h:88)
>   process_escape_args (process.c:103)
>   main (ovn-nbctl.c:92)
> Another leak shown at ovn-sbctl.c with similar pattern.
>
> Signed-off-by: William Tu <[email protected]>
> ---
>  ovn/utilities/ovn-nbctl.c | 1 +
>  ovn/utilities/ovn-sbctl.c | 1 +
>  2 files changed, 2 insertions(+)
>
> diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c
> index 5bdf757..e6d991f 100644
> --- a/ovn/utilities/ovn-nbctl.c
> +++ b/ovn/utilities/ovn-nbctl.c
> @@ -1295,6 +1295,7 @@ do_nbctl(const char *args, struct ctl_command
> *commands, size_t n_commands,
>      free(commands);
>      ovsdb_idl_txn_destroy(txn);
>      ovsdb_idl_destroy(idl);
> +    free(CONST_CAST(char *, args));
>
>      exit(EXIT_SUCCESS);
>
> diff --git a/ovn/utilities/ovn-sbctl.c b/ovn/utilities/ovn-sbctl.c
> index a888333..4877122 100644
> --- a/ovn/utilities/ovn-sbctl.c
> +++ b/ovn/utilities/ovn-sbctl.c
> @@ -973,6 +973,7 @@ do_sbctl(const char *args, struct ctl_command
> *commands, size_t n_commands,
>      free(commands);
>      ovsdb_idl_txn_destroy(txn);
>      ovsdb_idl_destroy(idl);
> +    free(CONST_CAST(char *, args));
>
>      exit(EXIT_SUCCESS);

While this will work, my preference in both cases would be to make
the call to free from inside the main block, so that the same
block allocates the memory and then frees it.

Ryan Moats
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

Reply via email to