From: Thomas Graf Date: Fri, 18 Jan 2013 13:49:08 +0000 (+0100) Subject: link: fix reference leak in rtnl_link_af_data_compare() X-Git-Tag: libnl3_2_20~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5291af6fb502e1bde7545a6eef261cdf40246110;p=libnl link: fix reference leak in rtnl_link_af_data_compare() Signed-off-by: Thomas Graf --- diff --git a/lib/route/link/api.c b/lib/route/link/api.c index 9387bc5..392ded3 100644 --- a/lib/route/link/api.c +++ b/lib/route/link/api.c @@ -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; } /** @} */