Netdev List
 help / color / mirror / Atom feed
From: gfree.wind@vip.163.com
To: xeb@mail.ru, davem@davemloft.net, netdev@vger.kernel.org
Cc: Gao Feng <gfree.wind@vip.163.com>
Subject: [PATCH net-next 1/1] driver: pptp: Remove unnecessary statements in pptp_sock_destruct
Date: Wed,  9 Aug 2017 23:57:56 +0800	[thread overview]
Message-ID: <1502294276-20051-1-git-send-email-gfree.wind@vip.163.com> (raw)

From: Gao Feng <gfree.wind@vip.163.com>

In the commit ddab82821fa6 ("ppp: Fix a scheduling-while-atomic bug in
del_chan"), I moved the synchronize_rcu() from del_chan() to pptp_release
after del_chan() to avoid one scheduling-while-atomic bug.

Actually the del_chan() and pppox_unbind_sock are unneccessary in the
pptp_sock_destruct. Because the pptp sock refcnt wouldn't reach zero until
sk_state is set as PPPOX_DEAD in pptp_release. By that time, the del_chan()
and pppox_unbind_sock() have been invoked already and the condition check
"!(sk->sk_state & PPPOX_DEAD)" of this sock must be false in pptp_sock_destruct.

So we could remove these statements in pptp_sock_destruct, and then restore
the synchronize_rcu() into del_chan.

Signed-off-by: Gao Feng <gfree.wind@vip.163.com>
---
 drivers/net/ppp/pptp.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c
index 6dde9a0..8632e1a 100644
--- a/drivers/net/ppp/pptp.c
+++ b/drivers/net/ppp/pptp.c
@@ -131,6 +131,7 @@ static void del_chan(struct pppox_sock *sock)
 	clear_bit(sock->proto.pptp.src_addr.call_id, callid_bitmap);
 	RCU_INIT_POINTER(callid_sock[sock->proto.pptp.src_addr.call_id], NULL);
 	spin_unlock(&chan_lock);
+	synchronize_rcu();
 }
 
 static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
@@ -519,7 +520,6 @@ static int pptp_release(struct socket *sock)
 
 	po = pppox_sk(sk);
 	del_chan(po);
-	synchronize_rcu();
 
 	pppox_unbind_sock(sk);
 	sk->sk_state = PPPOX_DEAD;
@@ -535,10 +535,6 @@ static int pptp_release(struct socket *sock)
 
 static void pptp_sock_destruct(struct sock *sk)
 {
-	if (!(sk->sk_state & PPPOX_DEAD)) {
-		del_chan(pppox_sk(sk));
-		pppox_unbind_sock(sk);
-	}
 	skb_queue_purge(&sk->sk_receive_queue);
 }
 
-- 
1.9.1

             reply	other threads:[~2017-08-09 16:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-09 15:57 gfree.wind [this message]
2017-08-09 18:08 ` [PATCH net-next 1/1] driver: pptp: Remove unnecessary statements in pptp_sock_destruct Cong Wang
2017-08-10  3:54   ` Gao Feng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1502294276-20051-1-git-send-email-gfree.wind@vip.163.com \
    --to=gfree.wind@vip.163.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=xeb@mail.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox