Skip to content

Commit

Permalink
openvswitch: Fix helper reference leak
Browse files Browse the repository at this point in the history
If the actions (re)allocation fails, or the actions list is larger than the
maximum size, and the conntrack action is the last action when these
problems are hit, then references to helper modules may be leaked. Fix
the issue.

Fixes: cae3a26 ("openvswitch: Allow attaching helpers to ct action")
Signed-off-by: Joe Stringer <[email protected]>
Acked-by: Pravin B Shelar <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
joestringer authored and davem330 committed Dec 12, 2015
1 parent 651df21 commit 2f3ab9f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion net/openvswitch/conntrack.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ struct ovs_conntrack_info {
struct md_labels labels;
};

static void __ovs_ct_free_action(struct ovs_conntrack_info *ct_info);

static u16 key_to_nfproto(const struct sw_flow_key *key)
{
switch (ntohs(key->eth.type)) {
Expand Down Expand Up @@ -708,7 +710,7 @@ int ovs_ct_copy_action(struct net *net, const struct nlattr *attr,
nf_conntrack_get(&ct_info.ct->ct_general);
return 0;
err_free_ct:
nf_conntrack_free(ct_info.ct);
__ovs_ct_free_action(&ct_info);
return err;
}

Expand Down Expand Up @@ -750,6 +752,11 @@ void ovs_ct_free_action(const struct nlattr *a)
{
struct ovs_conntrack_info *ct_info = nla_data(a);

__ovs_ct_free_action(ct_info);
}

static void __ovs_ct_free_action(struct ovs_conntrack_info *ct_info)
{
if (ct_info->helper)
module_put(ct_info->helper->me);
if (ct_info->ct)
Expand Down

0 comments on commit 2f3ab9f

Please sign in to comment.