[ovs-dev,ovn] lflow.c: Fix memory leak of lflow_ref_list_node->ref_name.
diff mbox series

Message ID 1571707604-48212-1-git-send-email-hzhou@ovn.org
State New
Headers show
Series
  • [ovs-dev,ovn] lflow.c: Fix memory leak of lflow_ref_list_node->ref_name.
Related show

Commit Message

Han Zhou Oct. 22, 2019, 1:26 a.m. UTC
The ref_name is copied in lflow_resource_add(), but forgot to free in
lflow_resource_destroy_lflow(). It can be fixed by freeing it in
lflow_resource_destroy_lflow(). However, this field is never really
used, so just delete it from lflow_ref_list_node, together with the
"type" field.

Fixes: d2aa2c7cafead ("ovn-controller: Maintain resource references for logical flows.")
Signed-off-by: Han Zhou <hzhou@ovn.org>
---
 controller/lflow.c | 2 --
 controller/lflow.h | 2 --
 2 files changed, 4 deletions(-)

Comments

Numan Siddique Oct. 22, 2019, 6:18 a.m. UTC | #1
On Tue, Oct 22, 2019 at 6:57 AM Han Zhou <hzhou@ovn.org> wrote:

> The ref_name is copied in lflow_resource_add(), but forgot to free in
> lflow_resource_destroy_lflow(). It can be fixed by freeing it in
> lflow_resource_destroy_lflow(). However, this field is never really
> used, so just delete it from lflow_ref_list_node, together with the
> "type" field.
>
> Fixes: d2aa2c7cafead ("ovn-controller: Maintain resource references for
> logical flows.")
> Signed-off-by: Han Zhou <hzhou@ovn.org>
>

Acked-by: Numan Siddique <numans@ovn.org>



> ---
>  controller/lflow.c | 2 --
>  controller/lflow.h | 2 --
>  2 files changed, 4 deletions(-)
>
> diff --git a/controller/lflow.c b/controller/lflow.c
> index e3ed20c..24e3a52 100644
> --- a/controller/lflow.c
> +++ b/controller/lflow.c
> @@ -230,8 +230,6 @@ lflow_resource_add(struct lflow_resource_ref *lfrr,
> enum ref_type type,
>      }
>
>      struct lflow_ref_list_node *lrln = xzalloc(sizeof *lrln);
> -    lrln->type = type;
> -    lrln->ref_name = xstrdup(ref_name);
>      lrln->lflow_uuid = *lflow_uuid;
>      ovs_list_push_back(&rlfn->ref_lflow_head, &lrln->ref_list);
>      ovs_list_push_back(&lfrn->lflow_ref_head, &lrln->lflow_list);
> diff --git a/controller/lflow.h b/controller/lflow.h
> index 0572668..abdc55e 100644
> --- a/controller/lflow.h
> +++ b/controller/lflow.h
> @@ -80,8 +80,6 @@ enum ref_type {
>  struct lflow_ref_list_node {
>      struct ovs_list lflow_list; /* list for same lflow */
>      struct ovs_list ref_list; /* list for same ref */
> -    enum ref_type type;
> -    char *ref_name;
>      struct uuid lflow_uuid;
>  };
>
> --
> 2.1.0
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
Han Zhou Oct. 22, 2019, 8:08 p.m. UTC | #2
On Mon, Oct 21, 2019 at 11:18 PM Numan Siddique <numans@ovn.org> wrote:
>
>
>
> On Tue, Oct 22, 2019 at 6:57 AM Han Zhou <hzhou@ovn.org> wrote:
>>
>> The ref_name is copied in lflow_resource_add(), but forgot to free in
>> lflow_resource_destroy_lflow(). It can be fixed by freeing it in
>> lflow_resource_destroy_lflow(). However, this field is never really
>> used, so just delete it from lflow_ref_list_node, together with the
>> "type" field.
>>
>> Fixes: d2aa2c7cafead ("ovn-controller: Maintain resource references for
logical flows.")
>> Signed-off-by: Han Zhou <hzhou@ovn.org>
>
>
> Acked-by: Numan Siddique <numans@ovn.org>
>
Thanks. I applied this to master. I will send a backport patch for 2.12.

Patch
diff mbox series

diff --git a/controller/lflow.c b/controller/lflow.c
index e3ed20c..24e3a52 100644
--- a/controller/lflow.c
+++ b/controller/lflow.c
@@ -230,8 +230,6 @@  lflow_resource_add(struct lflow_resource_ref *lfrr, enum ref_type type,
     }
 
     struct lflow_ref_list_node *lrln = xzalloc(sizeof *lrln);
-    lrln->type = type;
-    lrln->ref_name = xstrdup(ref_name);
     lrln->lflow_uuid = *lflow_uuid;
     ovs_list_push_back(&rlfn->ref_lflow_head, &lrln->ref_list);
     ovs_list_push_back(&lfrn->lflow_ref_head, &lrln->lflow_list);
diff --git a/controller/lflow.h b/controller/lflow.h
index 0572668..abdc55e 100644
--- a/controller/lflow.h
+++ b/controller/lflow.h
@@ -80,8 +80,6 @@  enum ref_type {
 struct lflow_ref_list_node {
     struct ovs_list lflow_list; /* list for same lflow */
     struct ovs_list ref_list; /* list for same ref */
-    enum ref_type type;
-    char *ref_name;
     struct uuid lflow_uuid;
 };