diff mbox series

[ovs-dev,v2,1/2] lldp: fix lldp memory leak

Message ID 568049c933ab704032b1a2a24a89308fa47e67bd.1653574451.git.lic121@chinatelecom.cn
State Accepted
Commit 509c32765a3218aafc44b036b1fd4e8e6c4d2d51
Headers show
Series fix revalidation triggers | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test fail github build: failed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Cheng Li May 26, 2022, 2:25 p.m. UTC
lldp_create() malloc memory for lldp->lldpd->g_hardware. lldp_unref
is supposed to free the memory regardless of hw->h_flags.

Signed-off-by: lic121 <lic121@chinatelecom.cn>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
---
 lib/lldp/lldpd.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

Comments

Paolo Valerio June 8, 2022, 5:14 p.m. UTC | #1
lic121 <lic121@chinatelecom.cn> writes:

> lldp_create() malloc memory for lldp->lldpd->g_hardware. lldp_unref
> is supposed to free the memory regardless of hw->h_flags.
>
> Signed-off-by: lic121 <lic121@chinatelecom.cn>
> Acked-by: Eelco Chaudron <echaudro@redhat.com>
> ---
>  lib/lldp/lldpd.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/lib/lldp/lldpd.c b/lib/lldp/lldpd.c
> index 403f1f5..4bff7b0 100644
> --- a/lib/lldp/lldpd.c
> +++ b/lib/lldp/lldpd.c
> @@ -140,13 +140,9 @@ lldpd_cleanup(struct lldpd *cfg)
>      VLOG_DBG("cleanup all ports");
>  
>      LIST_FOR_EACH_SAFE (hw, h_entries, &cfg->g_hardware) {
> -        if (!hw->h_flags) {
> -            ovs_list_remove(&hw->h_entries);
> -            lldpd_remote_cleanup(hw, NULL, true);
> -            lldpd_hardware_cleanup(cfg, hw);
> -        } else {
> -            lldpd_remote_cleanup(hw, NULL, false);
> -        }
> +        ovs_list_remove(&hw->h_entries);
> +        lldpd_remote_cleanup(hw, NULL, true);
> +        lldpd_hardware_cleanup(cfg, hw);
>      }
>  
>      VLOG_DBG("cleanup all chassis");


Acked-by: Paolo Valerio <pvalerio@redhat.com>
Ilya Maximets June 28, 2022, 4:14 p.m. UTC | #2
On 6/8/22 19:14, Paolo Valerio wrote:
> lic121 <lic121@chinatelecom.cn> writes:
> 
>> lldp_create() malloc memory for lldp->lldpd->g_hardware. lldp_unref
>> is supposed to free the memory regardless of hw->h_flags.
>>
>> Signed-off-by: lic121 <lic121@chinatelecom.cn>
>> Acked-by: Eelco Chaudron <echaudro@redhat.com>
>> ---
>>  lib/lldp/lldpd.c | 10 +++-------
>>  1 file changed, 3 insertions(+), 7 deletions(-)
>>
>> diff --git a/lib/lldp/lldpd.c b/lib/lldp/lldpd.c
>> index 403f1f5..4bff7b0 100644
>> --- a/lib/lldp/lldpd.c
>> +++ b/lib/lldp/lldpd.c
>> @@ -140,13 +140,9 @@ lldpd_cleanup(struct lldpd *cfg)
>>      VLOG_DBG("cleanup all ports");
>>  
>>      LIST_FOR_EACH_SAFE (hw, h_entries, &cfg->g_hardware) {
>> -        if (!hw->h_flags) {
>> -            ovs_list_remove(&hw->h_entries);
>> -            lldpd_remote_cleanup(hw, NULL, true);
>> -            lldpd_hardware_cleanup(cfg, hw);
>> -        } else {
>> -            lldpd_remote_cleanup(hw, NULL, false);
>> -        }
>> +        ovs_list_remove(&hw->h_entries);
>> +        lldpd_remote_cleanup(hw, NULL, true);
>> +        lldpd_hardware_cleanup(cfg, hw);
>>      }
>>  
>>      VLOG_DBG("cleanup all chassis");
> 
> 
> Acked-by: Paolo Valerio <pvalerio@redhat.com>

Thanks!  Applied and backported down to 2.13.

Best regards, Ilya Maximets.
diff mbox series

Patch

diff --git a/lib/lldp/lldpd.c b/lib/lldp/lldpd.c
index 403f1f5..4bff7b0 100644
--- a/lib/lldp/lldpd.c
+++ b/lib/lldp/lldpd.c
@@ -140,13 +140,9 @@  lldpd_cleanup(struct lldpd *cfg)
     VLOG_DBG("cleanup all ports");
 
     LIST_FOR_EACH_SAFE (hw, h_entries, &cfg->g_hardware) {
-        if (!hw->h_flags) {
-            ovs_list_remove(&hw->h_entries);
-            lldpd_remote_cleanup(hw, NULL, true);
-            lldpd_hardware_cleanup(cfg, hw);
-        } else {
-            lldpd_remote_cleanup(hw, NULL, false);
-        }
+        ovs_list_remove(&hw->h_entries);
+        lldpd_remote_cleanup(hw, NULL, true);
+        lldpd_hardware_cleanup(cfg, hw);
     }
 
     VLOG_DBG("cleanup all chassis");