aboutsummaryrefslogtreecommitdiffstats
path: root/net/irda/af_irda.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/irda/af_irda.c')
-rw-r--r--net/irda/af_irda.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index a0dbe07a1b19..e9aa1626ea89 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -131,14 +131,12 @@ static void irda_disconnect_indication(void *instance, void *sap,
131 } 131 }
132 132
133 /* Prevent race conditions with irda_release() and irda_shutdown() */ 133 /* Prevent race conditions with irda_release() and irda_shutdown() */
134 bh_lock_sock(sk);
134 if (!sock_flag(sk, SOCK_DEAD) && sk->sk_state != TCP_CLOSE) { 135 if (!sock_flag(sk, SOCK_DEAD) && sk->sk_state != TCP_CLOSE) {
135 lock_sock(sk);
136 sk->sk_state = TCP_CLOSE; 136 sk->sk_state = TCP_CLOSE;
137 sk->sk_err = ECONNRESET;
138 sk->sk_shutdown |= SEND_SHUTDOWN; 137 sk->sk_shutdown |= SEND_SHUTDOWN;
139 138
140 sk->sk_state_change(sk); 139 sk->sk_state_change(sk);
141 release_sock(sk);
142 140
143 /* Close our TSAP. 141 /* Close our TSAP.
144 * If we leave it open, IrLMP put it back into the list of 142 * If we leave it open, IrLMP put it back into the list of
@@ -158,6 +156,7 @@ static void irda_disconnect_indication(void *instance, void *sap,
158 self->tsap = NULL; 156 self->tsap = NULL;
159 } 157 }
160 } 158 }
159 bh_unlock_sock(sk);
161 160
162 /* Note : once we are there, there is not much you want to do 161 /* Note : once we are there, there is not much you want to do
163 * with the socket anymore, apart from closing it. 162 * with the socket anymore, apart from closing it.
@@ -1061,7 +1060,8 @@ static int irda_connect(struct socket *sock, struct sockaddr *uaddr,
1061 1060
1062 if (sk->sk_state != TCP_ESTABLISHED) { 1061 if (sk->sk_state != TCP_ESTABLISHED) {
1063 sock->state = SS_UNCONNECTED; 1062 sock->state = SS_UNCONNECTED;
1064 return sock_error(sk); /* Always set at this point */ 1063 err = sock_error(sk);
1064 return err? err : -ECONNRESET;
1065 } 1065 }
1066 1066
1067 sock->state = SS_CONNECTED; 1067 sock->state = SS_CONNECTED;
@@ -1355,7 +1355,9 @@ static int irda_recvmsg_dgram(struct kiocb *iocb, struct socket *sock,
1355 IRDA_DEBUG(4, "%s()\n", __FUNCTION__); 1355 IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
1356 1356
1357 IRDA_ASSERT(self != NULL, return -1;); 1357 IRDA_ASSERT(self != NULL, return -1;);
1358 IRDA_ASSERT(!sock_error(sk), return -1;); 1358
1359 if ((err = sock_error(sk)) < 0)
1360 return err;
1359 1361
1360 skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, 1362 skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,
1361 flags & MSG_DONTWAIT, &err); 1363 flags & MSG_DONTWAIT, &err);
@@ -1402,13 +1404,15 @@ static int irda_recvmsg_stream(struct kiocb *iocb, struct socket *sock,
1402 struct irda_sock *self = irda_sk(sk); 1404 struct irda_sock *self = irda_sk(sk);
1403 int noblock = flags & MSG_DONTWAIT; 1405 int noblock = flags & MSG_DONTWAIT;
1404 size_t copied = 0; 1406 size_t copied = 0;
1405 int target; 1407 int target, err;
1406 long timeo; 1408 long timeo;
1407 1409
1408 IRDA_DEBUG(3, "%s()\n", __FUNCTION__); 1410 IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
1409 1411
1410 IRDA_ASSERT(self != NULL, return -1;); 1412 IRDA_ASSERT(self != NULL, return -1;);
1411 IRDA_ASSERT(!sock_error(sk), return -1;); 1413
1414 if ((err = sock_error(sk)) < 0)
1415 return err;
1412 1416
1413 if (sock->flags & __SO_ACCEPTCON) 1417 if (sock->flags & __SO_ACCEPTCON)
1414 return(-EINVAL); 1418 return(-EINVAL);