]> granicus.if.org Git - libnl/commitdiff
link: fix reference leak in rtnl_link_af_data_compare()
authorThomas Graf <tgraf@suug.ch>
Fri, 18 Jan 2013 13:49:08 +0000 (14:49 +0100)
committerThomas Graf <tgraf@suug.ch>
Fri, 18 Jan 2013 13:49:33 +0000 (14:49 +0100)
Signed-off-by: Thomas Graf <tgraf@suug.ch>
lib/route/link/api.c

index 9387bc59319b2aac7b9aefbaec6ae9ab9f839c2e..392ded3004718cbb2738f4706f2faf0f12ab826e 100644 (file)
@@ -366,20 +366,25 @@ int rtnl_link_af_data_compare(struct rtnl_link *a, struct rtnl_link *b,
                              int family)
 {
        struct rtnl_link_af_ops *af_ops = rtnl_link_af_ops_lookup(family);
+       int ret = 0;
 
        if (!af_ops)
                return ~0;
 
        if (!a->l_af_data[family] && !b->l_af_data[family])
-               return 0;
+               goto out;
 
-       if (!a->l_af_data[family] || !b->l_af_data[family])
-               return ~0;
+       if (!a->l_af_data[family] || !b->l_af_data[family]) {
+               ret = ~0;
+               goto out;
+       }
 
        if (af_ops->ao_compare)
-               return af_ops->ao_compare(a, b, family, ~0, 0);
+               ret = af_ops->ao_compare(a, b, family, ~0, 0);
+out:
+       rtnl_link_af_ops_put(af_ops);
 
-       return 0;
+       return ret;
 }
 
 /** @} */