diff mbox

[1/2] X25: Fix x25_create errors for bad protocol and ENOBUFS

Message ID d45a3acc1002061516s3b3eab26tc2a9339613684e6f@mail.gmail.com
State Not Applicable, archived
Delegated to: David Miller
Headers show

Commit Message

andrew hendry Feb. 6, 2010, 11:16 p.m. UTC
alloc_socket failures should return -ENOBUFS
a bad protocol should return -EINVAL

Signed-off-by: Andrew Hendry <andrew.hendry@gmail.com>

---

Comments

David Miller Feb. 11, 2010, 1:54 a.m. UTC | #1
From: andrew hendry <andrew.hendry@gmail.com>
Date: Sun, 7 Feb 2010 10:16:59 +1100

> alloc_socket failures should return -ENOBUFS
> a bad protocol should return -EINVAL
> 
> Signed-off-by: Andrew Hendry <andrew.hendry@gmail.com>

Both of your patches were corrupted by your email client, so they
will not apply properly.

For example, long lines were chopped up into multiple lines.

See linux/Documentation/email-clients.txt for tips.

Please fix this up and resubmit your patches.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index e3219e4..6c7104e 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -512,15 +512,20 @@  static int x25_create(struct net *net, struct
socket *sock, int protocol,
 {
 	struct sock *sk;
 	struct x25_sock *x25;
-	int rc = -ESOCKTNOSUPPORT;
+	int rc = -EAFNOSUPPORT;

 	if (!net_eq(net, &init_net))
-		return -EAFNOSUPPORT;
+		goto out;
+
+	rc = -ESOCKTNOSUPPORT;
+	if (sock->type != SOCK_SEQPACKET)
+		goto out;

-	if (sock->type != SOCK_SEQPACKET || protocol)
+	rc = -EINVAL;
+	if (protocol)
 		goto out;

-	rc = -ENOMEM;
+	rc = -ENOBUFS;
 	if ((sk = x25_alloc_socket(net)) == NULL)
 		goto out;