From: Florian Westphal Date: Fri, 16 Feb 2018 11:49:32 +0000 (+0100) Subject: netfilter: ipt_CLUSTERIP: put config struct if we can't increment ct refcount X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=596816fabe42d41d81e862b056761bab50a93ae2;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git netfilter: ipt_CLUSTERIP: put config struct if we can't increment ct refcount [ Upstream commit 8ae56822812ddedc26a152ab1916eb30120b4748 ] This needs to put() the entry to avoid a resource leak in error path. Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c index c07e9db95ccc..171e74471a23 100644 --- a/net/ipv4/netfilter/ipt_CLUSTERIP.c +++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c @@ -492,12 +492,15 @@ static int clusterip_tg_check(const struct xt_tgchk_param *par) return PTR_ERR(config); } } - cipinfo->config = config; ret = nf_ct_netns_get(par->net, par->family); - if (ret < 0) + if (ret < 0) { pr_info("cannot load conntrack support for proto=%u\n", par->family); + clusterip_config_entry_put(par->net, config); + clusterip_config_put(config); + return ret; + } if (!par->net->xt.clusterip_deprecated_warning) { pr_info("ipt_CLUSTERIP is deprecated and it will removed soon, " @@ -505,6 +508,7 @@ static int clusterip_tg_check(const struct xt_tgchk_param *par) par->net->xt.clusterip_deprecated_warning = true; } + cipinfo->config = config; return ret; }