Skip to contentSkip to conversation

net_sched: check NULL in tcf_block_put()

PATCH Applied Cong Wang 3 participants 3 messages Nov 3, 2017

Subsystems (3)
lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH 1/1 net_sched: check NULL in tcf_block_put()

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")
Cc Jiri Pirko <[email protected]>
---
 net/sched/cls_api.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
net/sched/cls_api.c +2 -3
index a26c690b48ac..ad35bb4dffaa 100644
@@ -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);
 }
 
Signature · 1 line
2.13.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Fri, Nov 03, 2017 at 01:32:08AM CET, [email protected] 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")
Cc Jiri Pirko <[email protected]>
maintainer Applied
#2 lore raw
In reply to Cong Wang

From: Cong Wang <[email protected]>
Date: Thu, 2 Nov 2017 17:32:08 -0700

Quoted 11 lines

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")
Cc Jiri Pirko <[email protected]>

Applied, thanks Cong.