Commit f0b69a42 authored by Jeffy Chen's avatar Jeffy Chen Committed by Kleber Sacilotto de Souza

netfilter: nfnl_cthelper: Fix memory leak

BugLink: http://bugs.launchpad.net/bugs/1745054

[ Upstream commit f83bf8da ]

We have memory leaks of nf_conntrack_helper & expect_policy.
Signed-off-by: default avatarJeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
parent 19a6d6fe
...@@ -216,7 +216,7 @@ nfnl_cthelper_create(const struct nlattr * const tb[], ...@@ -216,7 +216,7 @@ nfnl_cthelper_create(const struct nlattr * const tb[],
ret = nfnl_cthelper_parse_expect_policy(helper, tb[NFCTH_POLICY]); ret = nfnl_cthelper_parse_expect_policy(helper, tb[NFCTH_POLICY]);
if (ret < 0) if (ret < 0)
goto err; goto err1;
strncpy(helper->name, nla_data(tb[NFCTH_NAME]), NF_CT_HELPER_NAME_LEN); strncpy(helper->name, nla_data(tb[NFCTH_NAME]), NF_CT_HELPER_NAME_LEN);
helper->data_len = ntohl(nla_get_be32(tb[NFCTH_PRIV_DATA_LEN])); helper->data_len = ntohl(nla_get_be32(tb[NFCTH_PRIV_DATA_LEN]));
...@@ -247,10 +247,12 @@ nfnl_cthelper_create(const struct nlattr * const tb[], ...@@ -247,10 +247,12 @@ nfnl_cthelper_create(const struct nlattr * const tb[],
ret = nf_conntrack_helper_register(helper); ret = nf_conntrack_helper_register(helper);
if (ret < 0) if (ret < 0)
goto err; goto err2;
return 0; return 0;
err: err2:
kfree(helper->expect_policy);
err1:
kfree(helper); kfree(helper);
return ret; return ret;
} }
...@@ -696,6 +698,8 @@ nfnl_cthelper_del(struct sock *nfnl, struct sk_buff *skb, ...@@ -696,6 +698,8 @@ nfnl_cthelper_del(struct sock *nfnl, struct sk_buff *skb,
found = true; found = true;
nf_conntrack_helper_unregister(cur); nf_conntrack_helper_unregister(cur);
kfree(cur->expect_policy);
kfree(cur);
} }
} }
/* Make sure we return success if we flush and there is no helpers */ /* Make sure we return success if we flush and there is no helpers */
...@@ -759,6 +763,8 @@ static void __exit nfnl_cthelper_exit(void) ...@@ -759,6 +763,8 @@ static void __exit nfnl_cthelper_exit(void)
continue; continue;
nf_conntrack_helper_unregister(cur); nf_conntrack_helper_unregister(cur);
kfree(cur->expect_policy);
kfree(cur);
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment