Commit 6e23ec0b authored by Hangyu Hua's avatar Hangyu Hua Committed by Jakub Kicinski
Browse files

net: sched: act_ct: fix possible refcount leak in tcf_ct_init()



nf_ct_put need to be called to put the refcount got by tcf_ct_fill_params
to avoid possible refcount leak when tcf_ct_flow_table_get fails.

Fixes: c34b961a ("net/sched: act_ct: Create nf flow table per zone")
Signed-off-by: default avatarHangyu Hua <hbh25y@gmail.com>
Link: https://lore.kernel.org/r/20220923020046.8021-1-hbh25y@gmail.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent a4320615
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -1394,7 +1394,7 @@ static int tcf_ct_init(struct net *net, struct nlattr *nla,

	err = tcf_ct_flow_table_get(net, params);
	if (err)
		goto cleanup;
		goto cleanup_params;

	spin_lock_bh(&c->tcf_lock);
	goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch);
@@ -1409,6 +1409,9 @@ static int tcf_ct_init(struct net *net, struct nlattr *nla,

	return res;

cleanup_params:
	if (params->tmpl)
		nf_ct_put(params->tmpl);
cleanup:
	if (goto_ch)
		tcf_chain_put_by_act(goto_ch);