diff mbox series

[ovs-dev,3/3] bfd: Fix memory leak

Message ID 1510757966-20364-3-git-send-email-pkusunyifeng@gmail.com
State Accepted
Delegated to: Ian Stokes
Headers show
Series [ovs-dev,1/3] dpif-netdev: Fix memory leak | expand

Commit Message

Yifeng Sun Nov. 15, 2017, 2:59 p.m. UTC
Valgrind complains in test 2359 ():

864 (576 direct, 288 indirect) bytes in 18 blocks are definitely
lost in loss record 96 of 101
   by 0x4A6D64: xmalloc (util.c:120)
   by 0x40BC04: gateway_chassis_get_ordered (gchassis.c:73)
   by 0x408CF0: bfd_calculate_chassis (bfd.c:219)
   by 0x408CF0: bfd_run (bfd.c:257)
   by 0x407F72: main (ovn-controller.c:718)

gateway_chassis wasn't released before the 'continue' line.

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

Comments

Gregory Rose Nov. 17, 2017, 6:02 p.m. UTC | #1
On 11/15/2017 6:59 AM, Yifeng Sun wrote:
> Valgrind complains in test 2359 ():
>
> 864 (576 direct, 288 indirect) bytes in 18 blocks are definitely
> lost in loss record 96 of 101
>     by 0x4A6D64: xmalloc (util.c:120)
>     by 0x40BC04: gateway_chassis_get_ordered (gchassis.c:73)
>     by 0x408CF0: bfd_calculate_chassis (bfd.c:219)
>     by 0x408CF0: bfd_run (bfd.c:257)
>     by 0x407F72: main (ovn-controller.c:718)
>
> gateway_chassis wasn't released before the 'continue' line.
>
> Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>

Looks good .

Tested-by: Greg Rose <gvrose8192@gmail.com>
Reviewed-by: Greg Rose <gvrose8192@gmail.com>

> ---
>   ovn/controller/bfd.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/ovn/controller/bfd.c b/ovn/controller/bfd.c
> index efc1482ecaa2..8f020d597083 100644
> --- a/ovn/controller/bfd.c
> +++ b/ovn/controller/bfd.c
> @@ -221,6 +221,7 @@ bfd_calculate_chassis(struct controller_ctx *ctx,
>                       /* we don't need BFD for non-HA  chassisredirect */
>                       if (!gateway_chassis ||
>                           ovs_list_is_short(gateway_chassis)) {
> +                        gateway_chassis_destroy(gateway_chassis);
>                           continue;
>                       }
>                       our_chassis_is_gw_for_dp = gateway_chassis_contains(
Ben Pfaff Nov. 29, 2017, 10:17 p.m. UTC | #2
On Wed, Nov 15, 2017 at 06:59:26AM -0800, Yifeng Sun wrote:
> Valgrind complains in test 2359 ():
> 
> 864 (576 direct, 288 indirect) bytes in 18 blocks are definitely
> lost in loss record 96 of 101
>    by 0x4A6D64: xmalloc (util.c:120)
>    by 0x40BC04: gateway_chassis_get_ordered (gchassis.c:73)
>    by 0x408CF0: bfd_calculate_chassis (bfd.c:219)
>    by 0x408CF0: bfd_run (bfd.c:257)
>    by 0x407F72: main (ovn-controller.c:718)
> 
> gateway_chassis wasn't released before the 'continue' line.
> 
> Signed-off-by: Yifeng Sun <pkusunyifeng@gmail.com>

Thanks, applied to master and branch-2.8.
diff mbox series

Patch

diff --git a/ovn/controller/bfd.c b/ovn/controller/bfd.c
index efc1482ecaa2..8f020d597083 100644
--- a/ovn/controller/bfd.c
+++ b/ovn/controller/bfd.c
@@ -221,6 +221,7 @@  bfd_calculate_chassis(struct controller_ctx *ctx,
                     /* we don't need BFD for non-HA  chassisredirect */
                     if (!gateway_chassis ||
                         ovs_list_is_short(gateway_chassis)) {
+                        gateway_chassis_destroy(gateway_chassis);
                         continue;
                     }
                     our_chassis_is_gw_for_dp = gateway_chassis_contains(