llc: avoid blocking in llc_sap_close()
authorCong Wang <xiyou.wangcong@gmail.com>
Tue, 11 Sep 2018 18:42:06 +0000 (11:42 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 13 Sep 2018 16:04:58 +0000 (09:04 -0700)
llc_sap_close() is called by llc_sap_put() which
could be called in BH context in llc_rcv(). We can't
block in BH.

There is no reason to block it here, kfree_rcu() should
be sufficient.

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/llc.h
net/llc/llc_core.c

index 890a87318014d528a78a3a9631ebdb75bf037a4b..df282d9b401704626b1824c70600c993a4ee1bb7 100644 (file)
@@ -66,6 +66,7 @@ struct llc_sap {
        int sk_count;
        struct hlist_nulls_head sk_laddr_hash[LLC_SK_LADDR_HASH_ENTRIES];
        struct hlist_head sk_dev_hash[LLC_SK_DEV_HASH_ENTRIES];
+       struct rcu_head rcu;
 };
 
 static inline
index 260b3dc1b4a2ab4545982b0b36478d6a6cf0b71f..64d4bef04e7302db8bec14965ed92ee5867b5a1d 100644 (file)
@@ -127,9 +127,7 @@ void llc_sap_close(struct llc_sap *sap)
        list_del_rcu(&sap->node);
        spin_unlock_bh(&llc_sap_list_lock);
 
-       synchronize_rcu();
-
-       kfree(sap);
+       kfree_rcu(sap, rcu);
 }
 
 static struct packet_type llc_packet_type __read_mostly = {