diff mbox series

[ovs-dev] ovn-ic: Destroy the created index row for ts.

Message ID 20231103155853.4137224-1-numans@ovn.org
State Accepted
Headers show
Series [ovs-dev] ovn-ic: Destroy the created index row for ts. | expand

Checks

Context Check Description
ovsrobot/apply-robot warning apply and check: warning
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/github-robot-_ovn-kubernetes success github build: passed

Commit Message

Numan Siddique Nov. 3, 2023, 3:58 p.m. UTC
From: Numan Siddique <numans@ovn.org>

Otherwise there would be a memory leak if
icnbrec_transit_switch_index_find() returns NULL.

Fixes: cf1b9920c48e("ovn-ic: fix potential segmentation violation when ts is deleted")
Signed-off-by: Numan Siddique <numans@ovn.org>
---
 ic/ovn-ic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mark Michelson Nov. 6, 2023, 5:05 p.m. UTC | #1
Thanks for the fix, Numan.

Acked-by: Mark Michelson <mmichels@redhat.com>

On 11/3/23 11:58, numans@ovn.org wrote:
> From: Numan Siddique <numans@ovn.org>
> 
> Otherwise there would be a memory leak if
> icnbrec_transit_switch_index_find() returns NULL.
> 
> Fixes: cf1b9920c48e("ovn-ic: fix potential segmentation violation when ts is deleted")
> Signed-off-by: Numan Siddique <numans@ovn.org>
> ---
>   ic/ovn-ic.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/ic/ovn-ic.c b/ic/ovn-ic.c
> index eec466ec4f..9c7b236cb4 100644
> --- a/ic/ovn-ic.c
> +++ b/ic/ovn-ic.c
> @@ -1638,11 +1638,11 @@ collect_lr_routes(struct ic_context *ctx,
>           icnbrec_transit_switch_index_set_name(key, isb_pb->transit_switch);
>           t_sw = icnbrec_transit_switch_index_find(
>                ctx->icnbrec_transit_switch_by_name, key);
> +        icnbrec_transit_switch_index_destroy_row(key);
>           if (!t_sw) {
>               continue;
>           }
>           ts_name = t_sw->name;
> -        icnbrec_transit_switch_index_destroy_row(key);
>           routes_ad = shash_find_data(routes_ad_by_ts, ts_name);
>           if (!routes_ad) {
>               routes_ad = xzalloc(sizeof *routes_ad);
Numan Siddique Nov. 6, 2023, 7:16 p.m. UTC | #2
On Mon, Nov 6, 2023 at 12:05 PM Mark Michelson <mmichels@redhat.com> wrote:
>
> Thanks for the fix, Numan.
>
> Acked-by: Mark Michelson <mmichels@redhat.com>

Thanks Mark.  Applied to main and branch-23.09.

Numan

>
> On 11/3/23 11:58, numans@ovn.org wrote:
> > From: Numan Siddique <numans@ovn.org>
> >
> > Otherwise there would be a memory leak if
> > icnbrec_transit_switch_index_find() returns NULL.
> >
> > Fixes: cf1b9920c48e("ovn-ic: fix potential segmentation violation when ts is deleted")
> > Signed-off-by: Numan Siddique <numans@ovn.org>
> > ---
> >   ic/ovn-ic.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/ic/ovn-ic.c b/ic/ovn-ic.c
> > index eec466ec4f..9c7b236cb4 100644
> > --- a/ic/ovn-ic.c
> > +++ b/ic/ovn-ic.c
> > @@ -1638,11 +1638,11 @@ collect_lr_routes(struct ic_context *ctx,
> >           icnbrec_transit_switch_index_set_name(key, isb_pb->transit_switch);
> >           t_sw = icnbrec_transit_switch_index_find(
> >                ctx->icnbrec_transit_switch_by_name, key);
> > +        icnbrec_transit_switch_index_destroy_row(key);
> >           if (!t_sw) {
> >               continue;
> >           }
> >           ts_name = t_sw->name;
> > -        icnbrec_transit_switch_index_destroy_row(key);
> >           routes_ad = shash_find_data(routes_ad_by_ts, ts_name);
> >           if (!routes_ad) {
> >               routes_ad = xzalloc(sizeof *routes_ad);
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
diff mbox series

Patch

diff --git a/ic/ovn-ic.c b/ic/ovn-ic.c
index eec466ec4f..9c7b236cb4 100644
--- a/ic/ovn-ic.c
+++ b/ic/ovn-ic.c
@@ -1638,11 +1638,11 @@  collect_lr_routes(struct ic_context *ctx,
         icnbrec_transit_switch_index_set_name(key, isb_pb->transit_switch);
         t_sw = icnbrec_transit_switch_index_find(
              ctx->icnbrec_transit_switch_by_name, key);
+        icnbrec_transit_switch_index_destroy_row(key);
         if (!t_sw) {
             continue;
         }
         ts_name = t_sw->name;
-        icnbrec_transit_switch_index_destroy_row(key);
         routes_ad = shash_find_data(routes_ad_by_ts, ts_name);
         if (!routes_ad) {
             routes_ad = xzalloc(sizeof *routes_ad);