From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cong Wang Subject: [Patch net-next] net_sched: check NULL in tcf_block_put() Date: Thu, 2 Nov 2017 17:32:08 -0700 Message-ID: <20171103003208.12329-1-xiyou.wangcong@gmail.com> Cc: dave.taht@gmail.com, Cong Wang , Jiri Pirko To: netdev@vger.kernel.org Return-path: Received: from mail-pg0-f68.google.com ([74.125.83.68]:45109 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934556AbdKCAcW (ORCPT ); Thu, 2 Nov 2017 20:32:22 -0400 Received: by mail-pg0-f68.google.com with SMTP id b192so1064381pga.2 for ; Thu, 02 Nov 2017 17:32:21 -0700 (PDT) Sender: netdev-owner@vger.kernel.org List-ID: 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 Cc: Jiri Pirko Signed-off-by: Cong Wang --- 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