[ovs-dev] dpif-netlink: Free leaked ofpbuf by using ofpbuf_delete
diff mbox series

Message ID 1551828421-1923-1-git-send-email-pkusunyifeng@gmail.com
State New
Headers show
Series
  • [ovs-dev] dpif-netlink: Free leaked ofpbuf by using ofpbuf_delete
Related show

Commit Message

Yifeng Sun March 5, 2019, 11:27 p.m. UTC
Found by valgrind.

256 bytes in 4 blocks are definitely lost in loss record 319 of 348
    by 0x52E204: xmalloc (util.c:123)
    by 0x4F6172: ofpbuf_new (ofpbuf.c:151)
    by 0x53DEF2: dpif_netlink_ct_get_limits (dpif-netlink.c:2951)
    by 0x587881: dpctl_ct_get_limits (dpctl.c:1904)
    by 0x58566F: dpctl_unixctl_handler (dpctl.c:2589)
    by 0x52D660: process_command (unixctl.c:308)
    by 0x52D660: run_connection (unixctl.c:342)
    by 0x52D660: unixctl_server_run (unixctl.c:393)
    by 0x407366: main (ovs-vswitchd.c:126)

Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
---
 lib/dpif-netlink.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Ben Pfaff March 6, 2019, 1:39 a.m. UTC | #1
On Tue, Mar 05, 2019 at 03:27:01PM -0800, Yifeng Sun wrote:
> Found by valgrind.
> 
> 256 bytes in 4 blocks are definitely lost in loss record 319 of 348
>     by 0x52E204: xmalloc (util.c:123)
>     by 0x4F6172: ofpbuf_new (ofpbuf.c:151)
>     by 0x53DEF2: dpif_netlink_ct_get_limits (dpif-netlink.c:2951)
>     by 0x587881: dpctl_ct_get_limits (dpctl.c:1904)
>     by 0x58566F: dpctl_unixctl_handler (dpctl.c:2589)
>     by 0x52D660: process_command (unixctl.c:308)
>     by 0x52D660: run_connection (unixctl.c:342)
>     by 0x52D660: unixctl_server_run (unixctl.c:393)
>     by 0x407366: main (ovs-vswitchd.c:126)
> 
> Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>

Thanks!  Applied to master, backported to 2.11 and 2.10.

Patch
diff mbox series

diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
index 73641a5b5b5a..00538e5e47d9 100644
--- a/lib/dpif-netlink.c
+++ b/lib/dpif-netlink.c
@@ -2884,7 +2884,7 @@  dpif_netlink_ct_set_limits(struct dpif *dpif OVS_UNUSED,
     nl_msg_end_nested(request, opt_offset);
 
     int err = nl_transact(NETLINK_GENERIC, request, NULL);
-    ofpbuf_uninit(request);
+    ofpbuf_delete(request);
     return err;
 }
 
@@ -2984,8 +2984,8 @@  dpif_netlink_ct_get_limits(struct dpif *dpif OVS_UNUSED,
                                                zone_limits_reply);
 
 out:
-    ofpbuf_uninit(request);
-    ofpbuf_uninit(reply);
+    ofpbuf_delete(request);
+    ofpbuf_delete(reply);
     return err;
 }
 
@@ -3021,7 +3021,7 @@  dpif_netlink_ct_del_limits(struct dpif *dpif OVS_UNUSED,
 
     int err = nl_transact(NETLINK_GENERIC, request, NULL);
 
-    ofpbuf_uninit(request);
+    ofpbuf_delete(request);
     return err;
 }