]> git.baikalelectronics.ru Git - kernel.git/commit
openvswitch: Fix template leak in error cases.
authorJoe Stringer <joe@ovn.org>
Wed, 23 Dec 2015 22:39:27 +0000 (14:39 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 29 Dec 2015 20:27:52 +0000 (15:27 -0500)
commit0734afe8d2fdcf4e9dd1deb066f4cc69e8ef55c8
tree33ca2fb418b80e805dddf278843ed143442e9451
parent7b0501be5cfe374d9a01ca6faf421909b56dab16
openvswitch: Fix template leak in error cases.

Commit 5b48bb8506c5 ("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: 33f290f71311 ("openvswitch: Allow attaching helpers to ct action")
Fixes: 5b48bb8506c5 ("openvswitch: Fix helper reference leak")
Signed-off-by: Joe Stringer <joe@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/openvswitch/conntrack.c