From 4a793a4235585d88a9e5f6e413bf59cf1abdd3db Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Tue, 5 Feb 2013 13:46:42 +0100 Subject: link: Hold af_ops reference for each AF_SPEC block during lifetime of link object Signed-off-by: Thomas Graf --- lib/route/link.c | 10 ++++++---- 1 file 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; } -- cgit v0.12