diff mbox series

[ovs-dev] northd: Fix memory leak.

Message ID YvydeL5vub9Mic+7@oseibert.fritz.box
State Accepted
Headers show
Series [ovs-dev] northd: Fix memory leak. | expand

Checks

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

Commit Message

Olaf Seibert Aug. 17, 2022, 7:49 a.m. UTC
Commit 7b56f69580e1f390d9c6753a2cb8f0dbfbb4c467 cloned the external_ids
to ids, then passed them to sbrec_port_binding_set_external_ids().
The intermediate step is unneeded (and caused a memory leak).
Pass the external_ids directly.

Signed-off-by: Olaf Seibert <o.seibert@syseleven.de>
---
 northd/northd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Ales Musil Aug. 17, 2022, 7:59 a.m. UTC | #1
On Wed, Aug 17, 2022 at 9:59 AM Olaf Seibert via dev <
ovs-dev@openvswitch.org> wrote:

> Commit 7b56f69580e1f390d9c6753a2cb8f0dbfbb4c467 cloned the external_ids
> to ids, then passed them to sbrec_port_binding_set_external_ids().
> The intermediate step is unneeded (and caused a memory leak).
> Pass the external_ids directly.
>
> Signed-off-by: Olaf Seibert <o.seibert@syseleven.de>
> ---
>  northd/northd.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/northd/northd.c b/northd/northd.c
> index 09eccf4d9..309b449dd 100644
> --- a/northd/northd.c
> +++ b/northd/northd.c
> @@ -3435,9 +3435,7 @@ ovn_port_update_sbrec(struct northd_input
> *input_data,
>          sbrec_port_binding_set_mac(op->sb, &addresses, 1);
>          ds_destroy(&s);
>
> -        struct smap ids = SMAP_INITIALIZER(&ids);
> -        smap_clone(&ids, &op->nbrp->external_ids);
> -        sbrec_port_binding_set_external_ids(op->sb, &ids);
> +        sbrec_port_binding_set_external_ids(op->sb,
> &op->nbrp->external_ids);
>
>          sbrec_port_binding_set_nat_addresses(op->sb, NULL, 0);
>      } else {
> --
> 2.37.2
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
>
Thanks!

Acked-by: Ales Musil <amusil@redhat.com>
Mark Michelson Aug. 17, 2022, 8:30 p.m. UTC | #2
Thanks Olaf and Ales, I have merged this to main, branch-22.06, and 
branch-22.03.

On 8/17/22 03:59, Ales Musil wrote:
> On Wed, Aug 17, 2022 at 9:59 AM Olaf Seibert via dev <
> ovs-dev@openvswitch.org> wrote:
> 
>> Commit 7b56f69580e1f390d9c6753a2cb8f0dbfbb4c467 cloned the external_ids
>> to ids, then passed them to sbrec_port_binding_set_external_ids().
>> The intermediate step is unneeded (and caused a memory leak).
>> Pass the external_ids directly.
>>
>> Signed-off-by: Olaf Seibert <o.seibert@syseleven.de>
>> ---
>>   northd/northd.c | 4 +---
>>   1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/northd/northd.c b/northd/northd.c
>> index 09eccf4d9..309b449dd 100644
>> --- a/northd/northd.c
>> +++ b/northd/northd.c
>> @@ -3435,9 +3435,7 @@ ovn_port_update_sbrec(struct northd_input
>> *input_data,
>>           sbrec_port_binding_set_mac(op->sb, &addresses, 1);
>>           ds_destroy(&s);
>>
>> -        struct smap ids = SMAP_INITIALIZER(&ids);
>> -        smap_clone(&ids, &op->nbrp->external_ids);
>> -        sbrec_port_binding_set_external_ids(op->sb, &ids);
>> +        sbrec_port_binding_set_external_ids(op->sb,
>> &op->nbrp->external_ids);
>>
>>           sbrec_port_binding_set_nat_addresses(op->sb, NULL, 0);
>>       } else {
>> --
>> 2.37.2
>>
>> _______________________________________________
>> dev mailing list
>> dev@openvswitch.org
>> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>>
>>
> Thanks!
> 
> Acked-by: Ales Musil <amusil@redhat.com>
>
diff mbox series

Patch

diff --git a/northd/northd.c b/northd/northd.c
index 09eccf4d9..309b449dd 100644
--- a/northd/northd.c
+++ b/northd/northd.c
@@ -3435,9 +3435,7 @@  ovn_port_update_sbrec(struct northd_input *input_data,
         sbrec_port_binding_set_mac(op->sb, &addresses, 1);
         ds_destroy(&s);
 
-        struct smap ids = SMAP_INITIALIZER(&ids);
-        smap_clone(&ids, &op->nbrp->external_ids);
-        sbrec_port_binding_set_external_ids(op->sb, &ids);
+        sbrec_port_binding_set_external_ids(op->sb, &op->nbrp->external_ids);
 
         sbrec_port_binding_set_nat_addresses(op->sb, NULL, 0);
     } else {