netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: andrew.hendry@gmail.com
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH 3/4] X.25 remove bkl in accept
Date: Tue, 14 Sep 2010 20:40:49 -0700 (PDT)	[thread overview]
Message-ID: <20100914.204049.104051991.davem@davemloft.net> (raw)
In-Reply-To: <1284507110.1742.56.camel@jaunty>

From: Andrew Hendry <andrew.hendry@gmail.com>
Date: Wed, 15 Sep 2010 09:31:50 +1000

> Accept already has socket locking.
> 
> Signed-off-by: Andrew Hendry <andrew.hendry@gmail.com>

Applied, but I took the liberty of moving the socket locking
above the TCP_LISTEN state check as follows:

--------------------
X.25 remove bkl in accept

Accept already has socket locking.

[ Extend socket locking over TCP_LISTEN state test. -DaveM ]

Signed-off-by: Andrew Hendry <andrew.hendry@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
 net/x25/af_x25.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index bd6fce3..04321ee 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -869,8 +869,7 @@ static int x25_accept(struct socket *sock, struct socket *newsock, int flags)
 	struct sk_buff *skb;
 	int rc = -EINVAL;
 
-	lock_kernel();
-	if (!sk || sk->sk_state != TCP_LISTEN)
+	if (!sk)
 		goto out;
 
 	rc = -EOPNOTSUPP;
@@ -878,6 +877,10 @@ static int x25_accept(struct socket *sock, struct socket *newsock, int flags)
 		goto out;
 
 	lock_sock(sk);
+	rc = -EINVAL;
+	if (sk->sk_state != TCP_LISTEN)
+		goto out2;
+
 	rc = x25_wait_for_data(sk, sk->sk_rcvtimeo);
 	if (rc)
 		goto out2;
@@ -897,7 +900,6 @@ static int x25_accept(struct socket *sock, struct socket *newsock, int flags)
 out2:
 	release_sock(sk);
 out:
-	unlock_kernel();
 	return rc;
 }
 
-- 
1.7.2.2


      reply	other threads:[~2010-09-15  3:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-14 23:31 [PATCH 3/4] X.25 remove bkl in accept Andrew Hendry
2010-09-15  3:40 ` David Miller [this message]

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=20100914.204049.104051991.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=andrew.hendry@gmail.com \
    --cc=netdev@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).