diff options
author | Joe Stringer <joe@ovn.org> | 2016-05-02 11:19:17 -0700 |
---|---|---|
committer | Joe Stringer <joe@ovn.org> | 2016-05-02 17:06:37 -0700 |
commit | a3a68d638a1035171f977375dead68d80d90521a (patch) | |
tree | 19dde0ae44e58844dd55a64f9cb415fd1143123e /datapath | |
parent | 66ec6da8e8203076236e6449b1b7e77b23b81a10 (diff) | |
download | openvswitch-a3a68d638a1035171f977375dead68d80d90521a.tar.gz |
datapath: Fix template leak in error cases.
Upstream commit:
openvswitch: Fix template leak in error cases.
Commit 2f3ab9f9fc23 ("openvswitch: Fix helper reference leak") fixed a
reference leak on helper objects, but inadvertently introduced a leak on
the ct template.
Previously, ct_info.ct->general.use was initialized to 0 by
nf_ct_tmpl_alloc() and only incremented when ovs_ct_copy_action()
returned successful. If an error occurred while adding the helper or
adding the action to the actions buffer, the __ovs_ct_free_action()
cleanup would use nf_ct_put() to free the entry; However, this relies on
atomic_dec_and_test(ct_info.ct->general.use). This reference must be
incremented first, or nf_ct_put() will never free it.
Fix the issue by acquiring a reference to the template immediately after
allocation.
Fixes: cae3a2627520 ("openvswitch: Allow attaching helpers to ct action")
Fixes: 2f3ab9f9fc23 ("openvswitch: Fix helper reference leak")
Signed-off-by: Joe Stringer <joe@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Upstream: 90c7afc96cbb ("openvswitch: Fix template leak in error cases.")
Fixes: 11251c170d92 ("datapath: Allow attaching helpers to ct action")
Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Jesse Gross <jesse@kernel.org>
Diffstat (limited to 'datapath')
-rw-r--r-- | datapath/conntrack.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/datapath/conntrack.c b/datapath/conntrack.c index 49c299b5b..13cacf423 100644 --- a/datapath/conntrack.c +++ b/datapath/conntrack.c @@ -695,6 +695,10 @@ int ovs_ct_copy_action(struct net *net, const struct nlattr *attr, OVS_NLERR(log, "Failed to allocate conntrack template"); return -ENOMEM; } + + __set_bit(IPS_CONFIRMED_BIT, &ct_info.ct->status); + nf_conntrack_get(&ct_info.ct->ct_general); + if (helper) { err = ovs_ct_add_helper(&ct_info, helper, key, log); if (err) @@ -706,8 +710,6 @@ int ovs_ct_copy_action(struct net *net, const struct nlattr *attr, if (err) goto err_free_ct; - __set_bit(IPS_CONFIRMED_BIT, &ct_info.ct->status); - nf_conntrack_get(&ct_info.ct->ct_general); return 0; err_free_ct: __ovs_ct_free_action(&ct_info); |