diff mbox series

[ovs-dev] utilities/ovn-appctl: free memory before exiting on failure

Message ID 20211019121955.486724-1-mheib@redhat.com
State Accepted
Headers show
Series [ovs-dev] utilities/ovn-appctl: free memory before exiting on failure | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/github-robot-_ovn-kubernetes fail github build: failed

Commit Message

Mohammad Heib Oct. 19, 2021, 12:19 p.m. UTC
From: Mohammad Heib <mheib@redhat.com>

unixctl_client_transact allocate memory using xstrdup and
this memory must be freed before exiting.

Signed-off-by: Mohammad Heib <mheib@redhat.com>
---
 utilities/ovn-appctl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Numan Siddique Oct. 20, 2021, 2:58 p.m. UTC | #1
On Tue, Oct 19, 2021 at 8:20 AM <mheib@redhat.com> wrote:
>
> From: Mohammad Heib <mheib@redhat.com>
>
> unixctl_client_transact allocate memory using xstrdup and
> this memory must be freed before exiting.
>
> Signed-off-by: Mohammad Heib <mheib@redhat.com>

Thanks.  I applied to the main branch.

Numan

> ---
>  utilities/ovn-appctl.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/utilities/ovn-appctl.c b/utilities/ovn-appctl.c
> index 912e96890..b90879346 100644
> --- a/utilities/ovn-appctl.c
> +++ b/utilities/ovn-appctl.c
> @@ -68,7 +68,8 @@ main(int argc, char *argv[])
>          jsonrpc_close(client);
>          fputs(cmd_error, stderr);
>          ovs_error(0, "%s: server returned an error", target);
> -        exit(2);
> +        free(cmd_error);
> +        error? exit(error) : exit(2);
>      } else if (cmd_result) {
>          fputs(cmd_result, stdout);
>      } else {
> --
> 2.27.0
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
diff mbox series

Patch

diff --git a/utilities/ovn-appctl.c b/utilities/ovn-appctl.c
index 912e96890..b90879346 100644
--- a/utilities/ovn-appctl.c
+++ b/utilities/ovn-appctl.c
@@ -68,7 +68,8 @@  main(int argc, char *argv[])
         jsonrpc_close(client);
         fputs(cmd_error, stderr);
         ovs_error(0, "%s: server returned an error", target);
-        exit(2);
+        free(cmd_error);
+        error? exit(error) : exit(2);
     } else if (cmd_result) {
         fputs(cmd_result, stdout);
     } else {