summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python-ethtool/etherinfo.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/python-ethtool/etherinfo.c b/python-ethtool/etherinfo.c
index 6670a85..6f7778c 100644
--- a/python-ethtool/etherinfo.c
+++ b/python-ethtool/etherinfo.c
@@ -191,11 +191,14 @@ int get_etherinfo(struct etherinfo_obj_data *data, nlQuery query)
link = rtnl_link_get_by_name(link_cache, ethinf->device);
if( !link ) {
+ nl_cache_free(link_cache);
return 0;
}
ethinf->index = rtnl_link_get_ifindex(link);
if( ethinf->index < 0 ) {
+ rtnl_link_put(link);
+ nl_cache_free(link_cache);
return 0;
}
rtnl_link_put(link);
@@ -220,6 +223,7 @@ int get_etherinfo(struct etherinfo_obj_data *data, nlQuery query)
case NLQRY_ADDR:
/* Extract IP address information */
if( rtnl_addr_alloc_cache(*data->nlc, &addr_cache) < 0) {
+ nl_cache_free(addr_cache);
return 0;
}
addr = rtnl_addr_alloc();
@@ -229,6 +233,8 @@ int get_etherinfo(struct etherinfo_obj_data *data, nlQuery query)
Py_XDECREF(ethinf->ipv4_addresses);
ethinf->ipv4_addresses = PyList_New(0);
if (!ethinf->ipv4_addresses) {
+ rtnl_addr_put(addr);
+ nl_cache_free(addr_cache);
return 0;
}
@@ -236,6 +242,8 @@ int get_etherinfo(struct etherinfo_obj_data *data, nlQuery query)
Py_XDECREF(ethinf->ipv6_addresses);
ethinf->ipv6_addresses = PyList_New(0);
if (!ethinf->ipv6_addresses) {
+ rtnl_addr_put(addr);
+ nl_cache_free(addr_cache);
return 0;
}