Skip to content

Commit 8f918d3

Browse files
congwangdavem330
authored andcommitted
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: 8c4083b ("net: sched: add block bind/unbind notif. and extended block_get/put") Reported-by: Dave Taht <[email protected]> Cc: Jiri Pirko <[email protected]> Signed-off-by: Cong Wang <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f67971e commit 8f918d3

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

net/sched/cls_api.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,6 @@ void tcf_block_put_ext(struct tcf_block *block,
340340
{
341341
struct tcf_chain *chain, *tmp;
342342

343-
if (!block)
344-
return;
345-
346343
list_for_each_entry_safe(chain, tmp, &block->chain_list, list)
347344
tcf_chain_flush(chain);
348345

@@ -362,6 +359,8 @@ void tcf_block_put(struct tcf_block *block)
362359
{
363360
struct tcf_block_ext_info ei = {0, };
364361

362+
if (!block)
363+
return;
365364
tcf_block_put_ext(block, NULL, block->q, &ei);
366365
}
367366

0 commit comments

Comments
 (0)