diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2008-06-03 18:18:36 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-06-03 18:18:36 -0400 |
commit | 9ecad877948deb2871d29e03786a7d7911687009 (patch) | |
tree | d54d027469630aa3b3cd4334b41dd3bc42e50871 /net | |
parent | 7dccf1f4e1696c79bff064c3770867cc53cbc71c (diff) |
irda: Sock leak on error path in irda_create.
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>
Diffstat (limited to 'net')
-rw-r--r-- | net/irda/af_irda.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c index ae54b20d0470..3eb5bcc75f99 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) | |||
1093 | 1093 | ||
1094 | init_waitqueue_head(&self->query_wait); | 1094 | init_waitqueue_head(&self->query_wait); |
1095 | 1095 | ||
1096 | /* Initialise networking socket struct */ | ||
1097 | sock_init_data(sock, sk); /* Note : set sk->sk_refcnt to 1 */ | ||
1098 | sk->sk_family = PF_IRDA; | ||
1099 | sk->sk_protocol = protocol; | ||
1100 | |||
1101 | switch (sock->type) { | 1096 | switch (sock->type) { |
1102 | case SOCK_STREAM: | 1097 | case SOCK_STREAM: |
1103 | sock->ops = &irda_stream_ops; | 1098 | sock->ops = &irda_stream_ops; |
@@ -1124,13 +1119,20 @@ static int irda_create(struct net *net, struct socket *sock, int protocol) | |||
1124 | self->max_sdu_size_rx = TTP_SAR_UNBOUND; | 1119 | self->max_sdu_size_rx = TTP_SAR_UNBOUND; |
1125 | break; | 1120 | break; |
1126 | default: | 1121 | default: |
1122 | sk_free(sk); | ||
1127 | return -ESOCKTNOSUPPORT; | 1123 | return -ESOCKTNOSUPPORT; |
1128 | } | 1124 | } |
1129 | break; | 1125 | break; |
1130 | default: | 1126 | default: |
1127 | sk_free(sk); | ||
1131 | return -ESOCKTNOSUPPORT; | 1128 | return -ESOCKTNOSUPPORT; |
1132 | } | 1129 | } |
1133 | 1130 | ||
1131 | /* Initialise networking socket struct */ | ||
1132 | sock_init_data(sock, sk); /* Note : set sk->sk_refcnt to 1 */ | ||
1133 | sk->sk_family = PF_IRDA; | ||
1134 | sk->sk_protocol = protocol; | ||
1135 | |||
1134 | /* Register as a client with IrLMP */ | 1136 | /* Register as a client with IrLMP */ |
1135 | self->ckey = irlmp_register_client(0, NULL, NULL, NULL); | 1137 | self->ckey = irlmp_register_client(0, NULL, NULL, NULL); |
1136 | self->mask.word = 0xffff; | 1138 | self->mask.word = 0xffff; |