net: sched: don't do tcf_chain_flush from tcf_chain_destroy
authorJiri Pirko <jiri@mellanox.com>
Tue, 22 Aug 2017 20:46:50 +0000 (22:46 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 22 Aug 2017 21:39:58 +0000 (14:39 -0700)
commit30d65e8f96ad01d9f998039e9af9ce5545e5a4ee
tree497408b42d7f0ee86b172ad3048944cb30997b14
parent744a4cf63e528c29840f45811d6fb93fd129b87d
net: sched: don't do tcf_chain_flush from tcf_chain_destroy

tcf_chain_flush needs to be called with RTNL. However, on
free_tcf->
 tcf_action_goto_chain_fini->
  tcf_chain_put->
   tcf_chain_destroy->
    tcf_chain_flush
callpath, it is called without RTNL.
This issue was notified by following warning:

[  155.599052] WARNING: suspicious RCU usage
[  155.603165] 4.13.0-rc5jiri+ #54 Not tainted
[  155.607456] -----------------------------
[  155.611561] net/sched/cls_api.c:195 suspicious rcu_dereference_protected() usage!

Since on this callpath, the chain is guaranteed to be already empty
by check in tcf_chain_put, move the tcf_chain_flush call out and call it
only where it is needed - into tcf_block_put.

Fixes: db50514f9a9c ("net: sched: add termination action to allow goto chain")
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/cls_api.c