summaryrefslogtreecommitdiffstats
path: root/lib/route/link.c
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2013-02-05 12:46:42 (GMT)
committerThomas Graf <tgraf@suug.ch>2013-02-05 12:46:42 (GMT)
commit4a793a4235585d88a9e5f6e413bf59cf1abdd3db (patch)
tree3b1d9cf6012517f7938d7076885be97d385778d9 /lib/route/link.c
parente5767684a6cae113c2fc4b1b16798a1b51595ab4 (diff)
downloadlibnl-4a793a4235585d88a9e5f6e413bf59cf1abdd3db.zip
libnl-4a793a4235585d88a9e5f6e413bf59cf1abdd3db.tar.gz
libnl-4a793a4235585d88a9e5f6e413bf59cf1abdd3db.tar.bz2
link: Hold af_ops reference for each AF_SPEC block during lifetime of link object
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Diffstat (limited to 'lib/route/link.c')
-rw-r--r--lib/route/link.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/route/link.c b/lib/route/link.c
index 26bd3da..99c5013 100644
--- a/lib/route/link.c
+++ b/lib/route/link.c
@@ -171,7 +171,11 @@ static int do_foreach_af(struct rtnl_link *link,
if (!(ops = rtnl_link_af_ops_lookup(i)))
BUG();
- if ((err = cb(link, ops, link->l_af_data[i], arg)) < 0)
+ err = cb(link, ops, link->l_af_data[i], arg);
+
+ rtnl_link_af_ops_put(ops);
+
+ if (err < 0)
return err;
}
}
@@ -201,6 +205,7 @@ static void link_free_data(struct nl_object *c)
if ((io = link->l_info_ops) != NULL)
release_link_info(link);
+ /* proto info af reference */
rtnl_link_af_ops_put(link->l_af_ops);
nl_addr_put(link->l_addr);
@@ -554,9 +559,6 @@ static int link_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
char *af_data = link->l_af_data[nla_type(af_attr)];
err = af_ops->ao_parse_af(link, af_attr, af_data);
-
- rtnl_link_af_ops_put(af_ops);
-
if (err < 0)
goto errout;
}