diff options
author | David Sommerseth <davids@redhat.com> | 2013-12-11 21:17:19 +0100 |
---|---|---|
committer | David Sommerseth <davids@redhat.com> | 2013-12-11 21:17:19 +0100 |
commit | f805e92004c51edcf3fe31de5f70371bbb7475b6 (patch) | |
tree | e1bf63d89bc8bd50dd3bdab10d70e9108455ce08 | |
parent | 732844796cc9cffa8b3245754933c16be0d9f940 (diff) | |
download | python-ethtool-f805e92004c51edcf3fe31de5f70371bbb7475b6.tar.gz python-ethtool-f805e92004c51edcf3fe31de5f70371bbb7475b6.tar.xz python-ethtool-f805e92004c51edcf3fe31de5f70371bbb7475b6.zip |
Fix a memleak which would happen if querying for a non-existing devicev0.9
Signed-off-by: David Sommerseth <davids@redhat.com>
-rw-r--r-- | python-ethtool/etherinfo.c | 8 |
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; } |