[ovs-dev] [branch 2.12] ovn-northd: fixed memory leak in ovn_port_update_sbrec()

nusiddiq at redhat.com nusiddiq at redhat.com
Tue Aug 6 11:04:02 UTC 2019


From: Damijan Skvarc <damjan.skvarc at gmail.com>

Memory leak happens because of redundand memory allocation for array
of single pointer. Issue was solved by removing this redundand allocation
and using address of pointer to created chassis sb_ha_entity instead.

Signed-off-by: Damijan Skvarc <damjan.skvarc at gmail.com>
Acked-by: Numan Siddique <nusiddiq at redhat.com>
Signed-off-by: Numan Siddique <nusiddiq at redhat.com>

(cherry-picked from ovn commit 800c4f338411c41d4d15d76073b8472f98f5a044)
---
 ovn/northd/ovn-northd.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
index ae09cf338..5d519c3f6 100644
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -2503,12 +2503,11 @@ ovn_port_update_sbrec(struct northd_context *ctx,
                     }
 
                     if (sb_ha_ch_grp->n_ha_chassis != 1) {
-                        struct sbrec_ha_chassis **sb_ha_ch =
-                            xcalloc(1, sizeof *sb_ha_ch);
-                        sb_ha_ch[0] = create_sb_ha_chassis(ctx, chassis,
-                                                           chassis->name, 0);
+                        struct sbrec_ha_chassis *sb_ha_ch =
+                            create_sb_ha_chassis(ctx, chassis,
+                                                 chassis->name, 0);
                         sbrec_ha_chassis_group_set_ha_chassis(sb_ha_ch_grp,
-                                                              sb_ha_ch, 1);
+                                                              &sb_ha_ch, 1);
                     }
                     sbrec_port_binding_set_ha_chassis_group(op->sb,
                                                             sb_ha_ch_grp);
-- 
2.21.0



More information about the dev mailing list