netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][IRDA]: Sock leak on error path in irda_create.
@ 2008-05-15 17:58 Pavel Emelyanov
  2008-06-03 22:18 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Emelyanov @ 2008-05-15 17:58 UTC (permalink / raw)
  To: Samuel Ortiz, Linux Netdev List

Bad type/protocol specified result in sk leak.

Fix is simple - release the sk if bad values are given,
but to make it possible just to call sk_free(), I move
some sk initialization a bit lower.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>

---

diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index ae54b20..3eb5bcc 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -1093,11 +1093,6 @@ static int irda_create(struct net *net, struct socket *sock, int protocol)
 
 	init_waitqueue_head(&self->query_wait);
 
-	/* Initialise networking socket struct */
-	sock_init_data(sock, sk);	/* Note : set sk->sk_refcnt to 1 */
-	sk->sk_family = PF_IRDA;
-	sk->sk_protocol = protocol;
-
 	switch (sock->type) {
 	case SOCK_STREAM:
 		sock->ops = &irda_stream_ops;
@@ -1124,13 +1119,20 @@ static int irda_create(struct net *net, struct socket *sock, int protocol)
 			self->max_sdu_size_rx = TTP_SAR_UNBOUND;
 			break;
 		default:
+			sk_free(sk);
 			return -ESOCKTNOSUPPORT;
 		}
 		break;
 	default:
+		sk_free(sk);
 		return -ESOCKTNOSUPPORT;
 	}
 
+	/* Initialise networking socket struct */
+	sock_init_data(sock, sk);	/* Note : set sk->sk_refcnt to 1 */
+	sk->sk_family = PF_IRDA;
+	sk->sk_protocol = protocol;
+
 	/* Register as a client with IrLMP */
 	self->ckey = irlmp_register_client(0, NULL, NULL, NULL);
 	self->mask.word = 0xffff;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH][IRDA]: Sock leak on error path in irda_create.
  2008-05-15 17:58 [PATCH][IRDA]: Sock leak on error path in irda_create Pavel Emelyanov
@ 2008-06-03 22:18 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2008-06-03 22:18 UTC (permalink / raw)
  To: xemul; +Cc: samuel, netdev

From: Pavel Emelyanov <xemul@openvz.org>
Date: Thu, 15 May 2008 21:58:41 +0400

> Bad type/protocol specified result in sk leak.
> 
> Fix is simple - release the sk if bad values are given,
> but to make it possible just to call sk_free(), I move
> some sk initialization a bit lower.
> 
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>

Applied, thanks Pavel.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-06-03 22:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-15 17:58 [PATCH][IRDA]: Sock leak on error path in irda_create Pavel Emelyanov
2008-06-03 22:18 ` David Miller

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).