All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net v2] net: sched: act_ct: fix possible refcount leak in tcf_ct_init()
@ 2022-09-23  2:00 Hangyu Hua
  2022-09-26 19:50 ` patchwork-bot+netdevbpf
  2022-10-01 19:55 ` Cong Wang
  0 siblings, 2 replies; 3+ messages in thread
From: Hangyu Hua @ 2022-09-23  2:00 UTC (permalink / raw)
  To: jhs, xiyou.wangcong, jiri, davem, edumazet, kuba, pabeni, paulb
  Cc: netdev, linux-kernel, Hangyu Hua

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: c34b961a2492 ("net/sched: act_ct: Create nf flow table per zone")
Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
---

v2: use a new label to put the refcount.

 net/sched/act_ct.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
index d55afb8d14be..5950974ae8f6 100644
--- a/net/sched/act_ct.c
+++ b/net/sched/act_ct.c
@@ -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);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] net: sched: act_ct: fix possible refcount leak in tcf_ct_init()
  2022-09-23  2:00 [PATCH net v2] net: sched: act_ct: fix possible refcount leak in tcf_ct_init() Hangyu Hua
@ 2022-09-26 19:50 ` patchwork-bot+netdevbpf
  2022-10-01 19:55 ` Cong Wang
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-09-26 19:50 UTC (permalink / raw)
  To: Hangyu Hua
  Cc: jhs, xiyou.wangcong, jiri, davem, edumazet, kuba, pabeni, paulb,
	netdev, linux-kernel

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 23 Sep 2022 10:00:46 +0800 you wrote:
> 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: c34b961a2492 ("net/sched: act_ct: Create nf flow table per zone")
> Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
> ---
> 
> [...]

Here is the summary with links:
  - [net,v2] net: sched: act_ct: fix possible refcount leak in tcf_ct_init()
    https://git.kernel.org/netdev/net/c/6e23ec0ba92d

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] net: sched: act_ct: fix possible refcount leak in tcf_ct_init()
  2022-09-23  2:00 [PATCH net v2] net: sched: act_ct: fix possible refcount leak in tcf_ct_init() Hangyu Hua
  2022-09-26 19:50 ` patchwork-bot+netdevbpf
@ 2022-10-01 19:55 ` Cong Wang
  1 sibling, 0 replies; 3+ messages in thread
From: Cong Wang @ 2022-10-01 19:55 UTC (permalink / raw)
  To: Hangyu Hua
  Cc: jhs, jiri, davem, edumazet, kuba, pabeni, paulb, netdev, linux-kernel

On Fri, Sep 23, 2022 at 10:00:46AM +0800, Hangyu Hua wrote:
> 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: c34b961a2492 ("net/sched: act_ct: Create nf flow table per zone")
> Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
> ---
> 
> v2: use a new label to put the refcount.
> 
>  net/sched/act_ct.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
> index d55afb8d14be..5950974ae8f6 100644
> --- a/net/sched/act_ct.c
> +++ b/net/sched/act_ct.c
> @@ -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);

Nit: this NULL check is unnecessary.

Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-01 19:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-23  2:00 [PATCH net v2] net: sched: act_ct: fix possible refcount leak in tcf_ct_init() Hangyu Hua
2022-09-26 19:50 ` patchwork-bot+netdevbpf
2022-10-01 19:55 ` Cong Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.