All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch net-next] net_sched: check NULL in tcf_block_put()
@ 2017-11-03  0:32 Cong Wang
  2017-11-03  6:56 ` Jiri Pirko
  2017-11-03 12:31 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Cong Wang @ 2017-11-03  0:32 UTC (permalink / raw)
  To: netdev; +Cc: dave.taht, Cong Wang, Jiri Pirko

Callers of tcf_block_put() could pass NULL so
we can't use block->q before checking if block is
NULL or not.

tcf_block_put_ext() callers are fine, it is always
non-NULL.

Fixes: 8c4083b30e56 ("net: sched: add block bind/unbind notif. and extended block_get/put")
Reported-by: Dave Taht <dave.taht@gmail.com>
Cc: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
 net/sched/cls_api.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index a26c690b48ac..ad35bb4dffaa 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -340,9 +340,6 @@ void tcf_block_put_ext(struct tcf_block *block,
 {
 	struct tcf_chain *chain, *tmp;
 
-	if (!block)
-		return;
-
 	tcf_block_offload_unbind(block, q, ei);
 
 	list_for_each_entry_safe(chain, tmp, &block->chain_list, list)
@@ -362,6 +359,8 @@ void tcf_block_put(struct tcf_block *block)
 {
 	struct tcf_block_ext_info ei = {0, };
 
+	if (!block)
+		return;
 	tcf_block_put_ext(block, NULL, block->q, &ei);
 }
 
-- 
2.13.0

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

* Re: [Patch net-next] net_sched: check NULL in tcf_block_put()
  2017-11-03  0:32 [Patch net-next] net_sched: check NULL in tcf_block_put() Cong Wang
@ 2017-11-03  6:56 ` Jiri Pirko
  2017-11-03 12:31 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Jiri Pirko @ 2017-11-03  6:56 UTC (permalink / raw)
  To: Cong Wang; +Cc: netdev, dave.taht, Jiri Pirko

Fri, Nov 03, 2017 at 01:32:08AM CET, xiyou.wangcong@gmail.com wrote:
>Callers of tcf_block_put() could pass NULL so
>we can't use block->q before checking if block is
>NULL or not.
>
>tcf_block_put_ext() callers are fine, it is always
>non-NULL.
>
>Fixes: 8c4083b30e56 ("net: sched: add block bind/unbind notif. and extended block_get/put")
>Reported-by: Dave Taht <dave.taht@gmail.com>
>Cc: Jiri Pirko <jiri@mellanox.com>
>Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>

Reviewed-by: Jiri Pirko <jiri@mellanox.com>

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

* Re: [Patch net-next] net_sched: check NULL in tcf_block_put()
  2017-11-03  0:32 [Patch net-next] net_sched: check NULL in tcf_block_put() Cong Wang
  2017-11-03  6:56 ` Jiri Pirko
@ 2017-11-03 12:31 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2017-11-03 12:31 UTC (permalink / raw)
  To: xiyou.wangcong; +Cc: netdev, dave.taht, jiri

From: Cong Wang <xiyou.wangcong@gmail.com>
Date: Thu,  2 Nov 2017 17:32:08 -0700

> Callers of tcf_block_put() could pass NULL so
> we can't use block->q before checking if block is
> NULL or not.
> 
> tcf_block_put_ext() callers are fine, it is always
> non-NULL.
> 
> Fixes: 8c4083b30e56 ("net: sched: add block bind/unbind notif. and extended block_get/put")
> Reported-by: Dave Taht <dave.taht@gmail.com>
> Cc: Jiri Pirko <jiri@mellanox.com>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>

Applied, thanks Cong.

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

end of thread, other threads:[~2017-11-03 12:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-03  0:32 [Patch net-next] net_sched: check NULL in tcf_block_put() Cong Wang
2017-11-03  6:56 ` Jiri Pirko
2017-11-03 12:31 ` David Miller

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.