diff mbox series

[ovs-dev,v2] ovsdb-client: fix memory leak to prevent valgrind reporting memory leaks while running test suite

Message ID 1570009072-25775-1-git-send-email-damjan.skvarc@gmail.com
State Accepted
Commit e7ea37ac922b0873942fab34a4cb81fe05667073
Headers show
Series [ovs-dev,v2] ovsdb-client: fix memory leak to prevent valgrind reporting memory leaks while running test suite | expand

Commit Message

Damijan Skvarc Oct. 2, 2019, 9:37 a.m. UTC
memory leaks are reported in several tests and are expressed in a following way:

==29840== 208 (48 direct, 160 indirect) bytes in 1 blocks are definitely lost in
 loss record 43 of 44
==29840==    at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64
-linux.so)
==29840==    by 0x449D12: xcalloc (util.c:121)
==29840==    by 0x432949: jsonrpc_msg_from_json (jsonrpc.c:697)
==29840==    by 0x432A8F: jsonrpc_parse_received_message (jsonrpc.c:472)
==29840==    by 0x432A8F: jsonrpc_recv.part.7 (jsonrpc.c:338)
==29840==    by 0x4338F7: jsonrpc_recv (jsonrpc.c:1139)
==29840==    by 0x4338F7: jsonrpc_session_recv (jsonrpc.c:1112)
==29840==    by 0x40719B: do_wait (ovsdb-client.c:2463)
==29840==    by 0x405F76: main (ovsdb-client.c:282)

Signed-off-by: Damijan Skvarc <damjan.skvarc@gmail.com>
---
 ovsdb/ovsdb-client.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Ben Pfaff Oct. 2, 2019, 2:49 p.m. UTC | #1
On Wed, Oct 02, 2019 at 11:37:52AM +0200, Damijan Skvarc wrote:
> memory leaks are reported in several tests and are expressed in a following way:
> 
> ==29840== 208 (48 direct, 160 indirect) bytes in 1 blocks are definitely lost in
>  loss record 43 of 44
> ==29840==    at 0x4C2FB55: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64
> -linux.so)
> ==29840==    by 0x449D12: xcalloc (util.c:121)
> ==29840==    by 0x432949: jsonrpc_msg_from_json (jsonrpc.c:697)
> ==29840==    by 0x432A8F: jsonrpc_parse_received_message (jsonrpc.c:472)
> ==29840==    by 0x432A8F: jsonrpc_recv.part.7 (jsonrpc.c:338)
> ==29840==    by 0x4338F7: jsonrpc_recv (jsonrpc.c:1139)
> ==29840==    by 0x4338F7: jsonrpc_session_recv (jsonrpc.c:1112)
> ==29840==    by 0x40719B: do_wait (ovsdb-client.c:2463)
> ==29840==    by 0x405F76: main (ovsdb-client.c:282)
> 
> Signed-off-by: Damijan Skvarc <damjan.skvarc@gmail.com>

Thanks.  I applied this to master.

I changed this exit(0) to exit(EXIT_FAILURE), since that's what
ovs_fatal() uses:

> -                    ovs_fatal(0, "%s: set_db_change_aware failed (%s)",
> +                    ovs_error(0, "%s: set_db_change_aware failed (%s)",
>                                jsonrpc_session_get_name(js),
>                                json_to_string(reply->error, 0));
> +                    jsonrpc_msg_destroy(reply);
> +                    exit(0);
Damijan Skvarc Oct. 3, 2019, 8:18 a.m. UTC | #2
Super, thanks

On Wed, Oct 2, 2019 at 5:31 PM Ben Pfaff <blp@ovn.org> wrote:

> On Wed, Oct 02, 2019 at 11:37:52AM +0200, Damijan Skvarc wrote:
> > memory leaks are reported in several tests and are expressed in a
> following way:
> >
> > ==29840== 208 (48 direct, 160 indirect) bytes in 1 blocks are definitely
> lost in
> >  loss record 43 of 44
> > ==29840==    at 0x4C2FB55: calloc (in
> /usr/lib/valgrind/vgpreload_memcheck-amd64
> > -linux.so)
> > ==29840==    by 0x449D12: xcalloc (util.c:121)
> > ==29840==    by 0x432949: jsonrpc_msg_from_json (jsonrpc.c:697)
> > ==29840==    by 0x432A8F: jsonrpc_parse_received_message (jsonrpc.c:472)
> > ==29840==    by 0x432A8F: jsonrpc_recv.part.7 (jsonrpc.c:338)
> > ==29840==    by 0x4338F7: jsonrpc_recv (jsonrpc.c:1139)
> > ==29840==    by 0x4338F7: jsonrpc_session_recv (jsonrpc.c:1112)
> > ==29840==    by 0x40719B: do_wait (ovsdb-client.c:2463)
> > ==29840==    by 0x405F76: main (ovsdb-client.c:282)
> >
> > Signed-off-by: Damijan Skvarc <damjan.skvarc@gmail.com>
>
> Thanks.  I applied this to master.
>
> I changed this exit(0) to exit(EXIT_FAILURE), since that's what
> ovs_fatal() uses:
>
> > -                    ovs_fatal(0, "%s: set_db_change_aware failed (%s)",
> > +                    ovs_error(0, "%s: set_db_change_aware failed (%s)",
> >                                jsonrpc_session_get_name(js),
> >                                json_to_string(reply->error, 0));
> > +                    jsonrpc_msg_destroy(reply);
> > +                    exit(0);
>
diff mbox series

Patch

diff --git a/ovsdb/ovsdb-client.c b/ovsdb/ovsdb-client.c
index e88e828..9a107a0 100644
--- a/ovsdb/ovsdb-client.c
+++ b/ovsdb/ovsdb-client.c
@@ -2468,12 +2468,15 @@  do_wait(struct jsonrpc *rpc_unused OVS_UNUSED,
         if (reply && reply->id) {
             if (sdca_id && json_equal(sdca_id, reply->id)) {
                 if (reply->type == JSONRPC_ERROR) {
-                    ovs_fatal(0, "%s: set_db_change_aware failed (%s)",
+                    ovs_error(0, "%s: set_db_change_aware failed (%s)",
                               jsonrpc_session_get_name(js),
                               json_to_string(reply->error, 0));
+                    jsonrpc_msg_destroy(reply);
+                    exit(0);
                 }
             } else if (txn_id && json_equal(txn_id, reply->id)) {
                 check_transaction_reply(reply);
+                jsonrpc_msg_destroy(reply);
                 exit(0);
             }
         }