aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-06-03 15:18:36 -0700
committerWilly Tarreau <w@1wt.eu>2010-09-05 22:47:17 +0200
commit2edf8d64ec17d33957ad70e9be2558f2419112a7 (patch)
tree64db46af619a3d121e174ad123c353c9d638284b
parent21f5f8cfb99d14d1418d31e99e3f37d53566c797 (diff)
downloadlinux-2.4-2edf8d64ec17d33957ad70e9be2558f2419112a7.tar.gz
irda: Sock leak on error path in irda_create.
(backported from 2.6 commit 9ecad877948deb2871d29e03786a7d7911687009) 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> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Willy Tarreau <w@1wt.eu>
-rw-r--r--net/irda/af_irda.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index 38b1dfe8f9dc71..3d198b1f7dea6c 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -1092,14 +1092,6 @@ static int irda_create(struct socket *sock, int protocol)
init_waitqueue_head(&self->query_wait);
- /* Initialise networking socket struct */
- sock_init_data(sock, sk); /* Note : set sk->refcnt to 1 */
- sk->family = PF_IRDA;
- sk->protocol = protocol;
- /* Link networking socket and IrDA socket structs together */
- sk->protinfo.irda = self;
- self->sk = sk;
-
switch (sock->type) {
case SOCK_STREAM:
sock->ops = &irda_stream_ops;
@@ -1123,13 +1115,23 @@ static int irda_create(struct socket *sock, int protocol)
break;
default:
ERROR("%s(), protocol not supported!\n", __FUNCTION__);
+ sk_free(sk);
return -ESOCKTNOSUPPORT;
}
break;
default:
+ sk_free(sk);
return -ESOCKTNOSUPPORT;
}
+ /* Initialise networking socket struct */
+ sock_init_data(sock, sk); /* Note : set sk->refcnt to 1 */
+ sk->family = PF_IRDA;
+ sk->protocol = protocol;
+ /* Link networking socket and IrDA socket structs together */
+ sk->protinfo.irda = self;
+ self->sk = sk;
+
/* Register as a client with IrLMP */
self->ckey = irlmp_register_client(0, NULL, NULL, NULL);
self->mask = 0xffff;