summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Vakhrushev <dmitry@netgate.com>2020-10-12 13:43:39 +0300
committerDmitry Vakhrushev <dmitry@netgate.com>2020-10-12 14:04:34 +0300
commitdecf51a86ac5df4892d0408b3770f7f8b3afe13d (patch)
treead30462047f3afecf797becb32b53568a8719044 /src
parent6b410e6d7c0f7c8de0453a6e8b19e408b0bd0158 (diff)
lldp: fix memory leakage
1. Typo in usage of vnet_hw_interface_add_del_mac_address(), which returns 0 when it succeeds instead non zero value. 2. Generated error doesn't clean allocated resources for an interface. 3. Returned value from vnet_hw_interface_add_del_mac_address() should be erased or reported. Type: fix Fixes: 149fd3fbd069a5f7be86e68472578ee7af229cb6 Signed-off-by: Dmitry Vakhrushev <dmitry@netgate.com> Change-Id: Ia6b28ae70fea127d15eb0102223ff972358766bc Signed-off-by: Dmitry Vakhrushev <dmitry@netgate.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/lldp/lldp_cli.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/plugins/lldp/lldp_cli.c b/src/plugins/lldp/lldp_cli.c
index da45ba3043b..d2cdf120e6e 100644
--- a/src/plugins/lldp/lldp_cli.c
+++ b/src/plugins/lldp/lldp_cli.c
@@ -49,6 +49,7 @@ lldp_cfg_err_t
lldp_cfg_intf_set (u32 hw_if_index, u8 ** port_desc, u8 ** mgmt_ip4,
u8 ** mgmt_ip6, u8 ** mgmt_oid, int enable)
{
+ clib_error_t *error = 0;
lldp_main_t *lm = &lldp_main;
vnet_main_t *vnm = lm->vnet_main;
ethernet_main_t *em = &ethernet_main;
@@ -101,10 +102,14 @@ lldp_cfg_intf_set (u32 hw_if_index, u8 ** port_desc, u8 ** mgmt_ip4,
*mgmt_oid = NULL;
}
- if (!vnet_hw_interface_add_del_mac_address (lm->vnet_main, hw_if_index,
- lldp_mac_addr,
- 1 /* is_add */ ))
+ error =
+ vnet_hw_interface_add_del_mac_address (lm->vnet_main, hw_if_index,
+ lldp_mac_addr,
+ 1 /* is_add */ );
+ if (error)
{
+ clib_error_free (error);
+ lldp_delete_intf (lm, n);
return lldp_internal_error;
}
@@ -121,9 +126,14 @@ lldp_cfg_intf_set (u32 hw_if_index, u8 ** port_desc, u8 ** mgmt_ip4,
lldp_delete_intf (lm, n);
if (n)
{
- vnet_hw_interface_add_del_mac_address (lm->vnet_main, hw_if_index,
- lldp_mac_addr,
- 0 /* is_add */ );
+ error =
+ vnet_hw_interface_add_del_mac_address (lm->vnet_main, hw_if_index,
+ lldp_mac_addr,
+ 0 /* is_add */ );
+ if (error)
+ {
+ clib_error_free (error);
+ }
}
}