Change in vdsm[ovirt-3.5]: vdsm: Fix memory leak in netlink.py

jtt77777 at yahoo.com jtt77777 at yahoo.com
Mon Mar 30 18:19:32 UTC 2015


John Taylor has uploaded a new change for review.

Change subject: vdsm: Fix memory leak in netlink.py
......................................................................

vdsm: Fix memory leak in netlink.py

The documentation for libnl says that calls to rtnl_link_get_by_name
increment the reference counter and should be released by a call to
rtnl_link_put().  That's not done in the get_link(name) function where
it is used and causes a memory leak.

Add a C function prototype for the libnl rtnl_link_put function,
construct the link_info, and call rtnl_link_put before returning from
get_link(name).

Change-Id: I6e4dc72bd77e46ba4f95dd8a622f5c3288115315
Signed-off-by: John Taylor <jtt77777 at yahoo.com>
---
M lib/vdsm/netlink.py
1 file changed, 5 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/72/39372/1

diff --git a/lib/vdsm/netlink.py b/lib/vdsm/netlink.py
index afae5ce..d822944 100644
--- a/lib/vdsm/netlink.py
+++ b/lib/vdsm/netlink.py
@@ -64,8 +64,9 @@
             if not link:
                 raise IOError(errno.ENODEV, '%s is not present in the system' %
                               name)
-            return _link_info(cache, link)
-
+            link_info = _link_info(cache, link)
+            _rtnl_link_put(link)
+            return link_info
 
 class NLSocketPool(object):
     """Pool of netlink sockets."""
@@ -332,5 +333,7 @@
 _nl_af2str = _int_char_proto(('nl_af2str', LIBNL))
 _rtnl_scope2str = _int_char_proto(('rtnl_scope2str', LIBNL_ROUTE))
 
+_rtnl_link_put  = _none_proto(('rtnl_link_put', LIBNL_ROUTE))
+
 _nl_link_cache = partial(_cache_manager, _rtnl_link_alloc_cache)
 _nl_addr_cache = partial(_cache_manager, _rtnl_addr_alloc_cache)


-- 
To view, visit https://gerrit.ovirt.org/39372
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6e4dc72bd77e46ba4f95dd8a622f5c3288115315
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: John Taylor <jtt77777 at yahoo.com>


More information about the vdsm-patches mailing list