diff mbox series

[ovs-dev,04/10] ovs-ofctl: Free leaked minimatch

Message ID 1568236716-18105-4-git-send-email-pkusunyifeng@gmail.com
State Accepted
Commit 3b6a5b737ae2f8f87320b52a6f5a3cbe1a0b1c0d
Headers show
Series [ovs-dev,01/10] raft: Free leaked json data | expand

Commit Message

Yifeng Sun Sept. 11, 2019, 9:18 p.m. UTC
Valgrind reported:

1056: ofproto - bundle with multiple flow mods (OpenFlow 1.4)

==19220== 160 bytes in 2 blocks are definitely lost in loss record 24 of 34
==19220==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==19220==    by 0x4979A4: xmalloc (util.c:138)
==19220==    by 0x42407D: miniflow_alloc (flow.c:3340)
==19220==    by 0x4296CF: minimatch_init (match.c:1758)
==19220==    by 0x46273D: parse_ofp_str__ (ofp-flow.c:1759)
==19220==    by 0x465B9E: parse_ofp_str (ofp-flow.c:1790)
==19220==    by 0x465CE0: parse_ofp_flow_mod_str (ofp-flow.c:1817)
==19220==    by 0x465DF6: parse_ofp_flow_mod_file (ofp-flow.c:1876)
==19220==    by 0x410BA3: ofctl_flow_mod_file.isra.19 (ovs-ofctl.c:1773)
==19220==    by 0x417933: ovs_cmdl_run_command__ (command-line.c:223)
==19220==    by 0x406F68: main (ovs-ofctl.c:179)

This patch fixes it.

Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
---
 utilities/ovs-ofctl.c | 1 +
 1 file changed, 1 insertion(+)

Comments

William Tu Sept. 17, 2019, 4:53 p.m. UTC | #1
On Wed, Sep 11, 2019 at 02:18:30PM -0700, Yifeng Sun wrote:
> Valgrind reported:
> 
> 1056: ofproto - bundle with multiple flow mods (OpenFlow 1.4)
> 
> ==19220== 160 bytes in 2 blocks are definitely lost in loss record 24 of 34
> ==19220==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==19220==    by 0x4979A4: xmalloc (util.c:138)
> ==19220==    by 0x42407D: miniflow_alloc (flow.c:3340)
> ==19220==    by 0x4296CF: minimatch_init (match.c:1758)
> ==19220==    by 0x46273D: parse_ofp_str__ (ofp-flow.c:1759)
> ==19220==    by 0x465B9E: parse_ofp_str (ofp-flow.c:1790)
> ==19220==    by 0x465CE0: parse_ofp_flow_mod_str (ofp-flow.c:1817)
> ==19220==    by 0x465DF6: parse_ofp_flow_mod_file (ofp-flow.c:1876)
> ==19220==    by 0x410BA3: ofctl_flow_mod_file.isra.19 (ovs-ofctl.c:1773)
> ==19220==    by 0x417933: ovs_cmdl_run_command__ (command-line.c:223)
> ==19220==    by 0x406F68: main (ovs-ofctl.c:179)
> 
> This patch fixes it.
> 
> Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>
Looks good to me.

Acked-by: William Tu <u9012063@gmail.com>
> ---
>  utilities/ovs-ofctl.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
> index 754629d3dfbb..06289d296573 100644
> --- a/utilities/ovs-ofctl.c
> +++ b/utilities/ovs-ofctl.c
> @@ -1724,6 +1724,7 @@ bundle_flow_mod__(const char *remote, struct ofputil_flow_mod *fms,
>  
>          ovs_list_push_back(&requests, &request->list_node);
>          free(CONST_CAST(struct ofpact *, fm->ofpacts));
> +        minimatch_destroy(&fm->match);
>      }
>  
>      bundle_transact(vconn, &requests, OFPBF_ORDERED | OFPBF_ATOMIC);
> -- 
> 2.7.4
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
diff mbox series

Patch

diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index 754629d3dfbb..06289d296573 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -1724,6 +1724,7 @@  bundle_flow_mod__(const char *remote, struct ofputil_flow_mod *fms,
 
         ovs_list_push_back(&requests, &request->list_node);
         free(CONST_CAST(struct ofpact *, fm->ofpacts));
+        minimatch_destroy(&fm->match);
     }
 
     bundle_transact(vconn, &requests, OFPBF_ORDERED | OFPBF_ATOMIC);