[PATCH 7/7] core: Fix leaks if address parsing fails while setting mac



Both 'old' and 'new' are leaked if nl_addr_build() fails to parse
the mac address.
---
 src/nm-system.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/nm-system.c b/src/nm-system.c
index 7fa4b6a..0b29468 100644
--- a/src/nm-system.c
+++ b/src/nm-system.c
@@ -755,6 +755,8 @@ nm_system_iface_set_mac (int ifindex, const struct ether_addr *mac)
 		addr = nl_addr_build (AF_LLC, (void *) mac, ETH_ALEN);
 		if (!addr) {
 			nm_log_err (LOGD_HW, "(%s): failed to allocate memory for MAC address change", iface);
+			rtnl_link_put (old);
+			rtnl_link_put (new);
 			return FALSE;
 		}
 		rtnl_link_set_addr (new, addr);
-- 
1.7.6



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]