summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJonas Gorski <jonas.gorski@bisdn.de>2024-07-16 14:01:27 (GMT)
committerThomas Haller <thaller@redhat.com>2024-08-19 06:44:43 (GMT)
commit64fad14bc9c5b594f9ffcd1aa0ca7e00042d8350 (patch)
tree58bd110bcb01cbc4ed8a14b2b564777251528a3c /lib
parent277eb32c2c2c890e7a6de848401182ff322a4dea (diff)
downloadlibnl-64fad14bc9c5b594f9ffcd1aa0ca7e00042d8350.zip
libnl-64fad14bc9c5b594f9ffcd1aa0ca7e00042d8350.tar.gz
libnl-64fad14bc9c5b594f9ffcd1aa0ca7e00042d8350.tar.bz2
link: link_msg_parser(): keep link info instead of release and reacquire
Calling release_link_info() will call io_free() for rtnl_link::l_info was allocated just a few lines before as a side effect of rtnl_link_set_type(). Apart from doing needless memory churn, this will also leave the link with l_info set to NULL if the link type does not provide a io_parse() function. Assuming the memory leak mentioned in bfee88b8b0a9 ("route: fix memory leak of l_info_ops in link_msg_parser()") was a double reference taken by calling rtnl_link_info_ops_lookup() twice, once via rtnl_link_set_type(), and once directly, replace the lookup() / release() lookup() with a single lookup() and then reuse the populated rtnl_link::l_info_ops pointer. Fixes: bfee88b8b0a9 ("route: fix memory leak of l_info_ops in link_msg_parser()") Signed-off-by: Jonas Gorski <jonas.gorski@bisdn.de> https://github.com/thom311/libnl/pull/396
Diffstat (limited to 'lib')
-rw-r--r--lib/route/link.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/lib/route/link.c b/lib/route/link.c
index e634a8b..2603bc8 100644
--- a/lib/route/link.c
+++ b/lib/route/link.c
@@ -681,11 +681,7 @@ static int link_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
tb[IFLA_PROTINFO] = (struct nlattr *)link->l_af_ops->ao_protinfo_policy;
}
- if (link->l_info_ops)
- release_link_info(link);
-
- ops = rtnl_link_info_ops_lookup(kind);
- link->l_info_ops = ops;
+ ops = link->l_info_ops;
if (ops) {
if (ops->io_parse &&