netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: sched: fix unbalance in the error path of tca_action_flush()
@ 2018-02-15 14:50 Davide Caratti
  2018-02-15 15:31 ` Jamal Hadi Salim
  2018-02-16 20:43 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Davide Caratti @ 2018-02-15 14:50 UTC (permalink / raw)
  To: Jiri Pirko, Cong Wang, Jamal Hadi Salim, David S. Miller; +Cc: netdev

When tca_action_flush() calls the action walk() and gets an error,
a successful call to nla_nest_start() is not followed by a call to
nla_nest_cancel(). It's harmless, as the skb is freed in the error
path - but it's worth to fix this unbalance.

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
---
 net/sched/act_api.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index eba6682727dd..43f4991b7777 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -938,8 +938,10 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
 		goto out_module_put;
 
 	err = ops->walk(net, skb, &dcb, RTM_DELACTION, ops);
-	if (err <= 0)
+	if (err <= 0) {
+		nla_nest_cancel(skb, nest);
 		goto out_module_put;
+	}
 
 	nla_nest_end(skb, nest);
 
-- 
2.14.3

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

* Re: [PATCH net] net: sched: fix unbalance in the error path of tca_action_flush()
  2018-02-15 14:50 [PATCH net] net: sched: fix unbalance in the error path of tca_action_flush() Davide Caratti
@ 2018-02-15 15:31 ` Jamal Hadi Salim
  2018-02-15 19:05   ` Davide Caratti
  2018-02-16 20:43 ` David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Jamal Hadi Salim @ 2018-02-15 15:31 UTC (permalink / raw)
  To: Davide Caratti, Jiri Pirko, Cong Wang, David S. Miller; +Cc: netdev

On 18-02-15 09:50 AM, Davide Caratti wrote:
> When tca_action_flush() calls the action walk() and gets an error,
> a successful call to nla_nest_start() is not followed by a call to
> nla_nest_cancel(). It's harmless, as the skb is freed in the error
> path - but it's worth to fix this unbalance.

Kind of pushing the boundaries saying this targets net tree - there is
no bug you are fixing (as you say the sk is freed).
Maybe it makes the code prettier ...

cheers,
jamal

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

* Re: [PATCH net] net: sched: fix unbalance in the error path of tca_action_flush()
  2018-02-15 15:31 ` Jamal Hadi Salim
@ 2018-02-15 19:05   ` Davide Caratti
  0 siblings, 0 replies; 4+ messages in thread
From: Davide Caratti @ 2018-02-15 19:05 UTC (permalink / raw)
  To: Jamal Hadi Salim, Jiri Pirko, Cong Wang, David S. Miller; +Cc: netdev

On Thu, 2018-02-15 at 10:31 -0500, Jamal Hadi Salim wrote:
> On 18-02-15 09:50 AM, Davide Caratti wrote:
> > When tca_action_flush() calls the action walk() and gets an error,
> > a successful call to nla_nest_start() is not followed by a call to
> > nla_nest_cancel(). It's harmless, as the skb is freed in the error
> > path - but it's worth to fix this unbalance.
> 
> Kind of pushing the boundaries saying this targets net tree - there is
> no bug you are fixing (as you say the sk is freed).
> Maybe it makes the code prettier ...

you are right, this fix is only cosmetic as long as the skb is no more
used after walk() returns an error. It just triggered the doubt to me
while I was reading the series that added support to ext_acks, and this is
the followup.

David, please apply to net-next (or drop it, at your convenience).

thank you in advance,
-- 
davide

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

* Re: [PATCH net] net: sched: fix unbalance in the error path of tca_action_flush()
  2018-02-15 14:50 [PATCH net] net: sched: fix unbalance in the error path of tca_action_flush() Davide Caratti
  2018-02-15 15:31 ` Jamal Hadi Salim
@ 2018-02-16 20:43 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2018-02-16 20:43 UTC (permalink / raw)
  To: dcaratti; +Cc: jiri, xiyou.wangcong, jhs, netdev

From: Davide Caratti <dcaratti@redhat.com>
Date: Thu, 15 Feb 2018 15:50:57 +0100

> When tca_action_flush() calls the action walk() and gets an error,
> a successful call to nla_nest_start() is not followed by a call to
> nla_nest_cancel(). It's harmless, as the skb is freed in the error
> path - but it's worth to fix this unbalance.
> 
> Signed-off-by: Davide Caratti <dcaratti@redhat.com>

Applied to net-next, thanks.

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

end of thread, other threads:[~2018-02-16 20:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-15 14:50 [PATCH net] net: sched: fix unbalance in the error path of tca_action_flush() Davide Caratti
2018-02-15 15:31 ` Jamal Hadi Salim
2018-02-15 19:05   ` Davide Caratti
2018-02-16 20:43 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).