From mboxrd@z Thu Jan 1 00:00:00 1970 From: James Chapman Subject: [PATCH net-next v3 08/16] l2tp: hide session from pppol2tp_sock_to_session if it is closing Date: Mon, 12 Feb 2018 17:33:31 +0000 Message-ID: <1518456819-22244-9-git-send-email-jchapman@katalix.com> References: <1518456819-22244-1-git-send-email-jchapman@katalix.com> To: netdev@vger.kernel.org Return-path: Received: from mail.katalix.com ([82.103.140.233]:38753 "EHLO mail.katalix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753530AbeBLRdp (ORCPT ); Mon, 12 Feb 2018 12:33:45 -0500 Received: from katalix.com (82-69-108-24.dsl.in-addr.zen.co.uk [82.69.108.24]) (Authenticated sender: james) by mail.katalix.com (Postfix) with ESMTPSA id 6E4B34E8FF for ; Mon, 12 Feb 2018 17:33:43 +0000 (GMT) In-Reply-To: <1518456819-22244-1-git-send-email-jchapman@katalix.com> Sender: netdev-owner@vger.kernel.org List-ID: Signed-off-by: James Chapman --- net/l2tp/l2tp_ppp.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c index ff95a4d4eac5..947066b3d6d8 100644 --- a/net/l2tp/l2tp_ppp.c +++ b/net/l2tp/l2tp_ppp.c @@ -172,8 +172,16 @@ static inline struct l2tp_session *pppol2tp_sock_to_session(struct sock *sk) rcu_read_unlock_bh(); return NULL; } + + spin_lock_bh(&session->lock); + if (session->closing) { + spin_unlock_bh(&session->lock); + rcu_read_unlock_bh(); + return NULL; + } l2tp_session_inc_refcount(session); - rcu_read_unlock(); + spin_unlock_bh(&session->lock); + rcu_read_unlock_bh(); BUG_ON(session->magic != L2TP_SESSION_MAGIC); -- 1.9.1