diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-04-27 12:26:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-04-27 12:26:46 -0400 |
commit | 15c54033964a943de7b0763efd3bd0ede7326395 (patch) | |
tree | 840b292612d1b5396d5bab5bde537a9013db3ceb /net/irda/af_irda.c | |
parent | ad5da3cf39a5b11a198929be1f2644e17ecd767e (diff) | |
parent | 912a41a4ab935ce8c4308428ec13fc7f8b1f18f4 (diff) |
Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6: (448 commits)
[IPV4] nl_fib_lookup: Initialise res.r before fib_res_put(&res)
[IPV6]: Fix thinko in ipv6_rthdr_rcv() changes.
[IPV4]: Add multipath cached to feature-removal-schedule.txt
[WIRELESS] cfg80211: Clarify locking comment.
[WIRELESS] cfg80211: Fix locking in wiphy_new.
[WEXT] net_device: Don't include wext bits if not required.
[WEXT]: Misc code cleanups.
[WEXT]: Reduce inline abuse.
[WEXT]: Move EXPORT_SYMBOL statements where they belong.
[WEXT]: Cleanup early ioctl call path.
[WEXT]: Remove options.
[WEXT]: Remove dead debug code.
[WEXT]: Clean up how wext is called.
[WEXT]: Move to net/wireless
[AFS]: Eliminate cmpxchg() usage in vlocation code.
[RXRPC]: Fix pointers passed to bitops.
[RXRPC]: Remove bogus atomic_* overrides.
[AFS]: Fix u64 printing in debug logging.
[AFS]: Add "directory write" support.
[AFS]: Implement the CB.InitCallBackState3 operation.
...
Diffstat (limited to 'net/irda/af_irda.c')
-rw-r--r-- | net/irda/af_irda.c | 136 |
1 files changed, 47 insertions, 89 deletions
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c index 0eb7d596d470..06c97c60d542 100644 --- a/net/irda/af_irda.c +++ b/net/irda/af_irda.c | |||
@@ -89,7 +89,6 @@ static int irda_data_indication(void *instance, void *sap, struct sk_buff *skb) | |||
89 | 89 | ||
90 | self = instance; | 90 | self = instance; |
91 | sk = instance; | 91 | sk = instance; |
92 | IRDA_ASSERT(sk != NULL, return -1;); | ||
93 | 92 | ||
94 | err = sock_queue_rcv_skb(sk, skb); | 93 | err = sock_queue_rcv_skb(sk, skb); |
95 | if (err) { | 94 | if (err) { |
@@ -131,14 +130,12 @@ static void irda_disconnect_indication(void *instance, void *sap, | |||
131 | } | 130 | } |
132 | 131 | ||
133 | /* Prevent race conditions with irda_release() and irda_shutdown() */ | 132 | /* Prevent race conditions with irda_release() and irda_shutdown() */ |
133 | bh_lock_sock(sk); | ||
134 | if (!sock_flag(sk, SOCK_DEAD) && sk->sk_state != TCP_CLOSE) { | 134 | if (!sock_flag(sk, SOCK_DEAD) && sk->sk_state != TCP_CLOSE) { |
135 | lock_sock(sk); | ||
136 | sk->sk_state = TCP_CLOSE; | 135 | sk->sk_state = TCP_CLOSE; |
137 | sk->sk_err = ECONNRESET; | ||
138 | sk->sk_shutdown |= SEND_SHUTDOWN; | 136 | sk->sk_shutdown |= SEND_SHUTDOWN; |
139 | 137 | ||
140 | sk->sk_state_change(sk); | 138 | sk->sk_state_change(sk); |
141 | release_sock(sk); | ||
142 | 139 | ||
143 | /* Close our TSAP. | 140 | /* Close our TSAP. |
144 | * If we leave it open, IrLMP put it back into the list of | 141 | * If we leave it open, IrLMP put it back into the list of |
@@ -158,6 +155,7 @@ static void irda_disconnect_indication(void *instance, void *sap, | |||
158 | self->tsap = NULL; | 155 | self->tsap = NULL; |
159 | } | 156 | } |
160 | } | 157 | } |
158 | bh_unlock_sock(sk); | ||
161 | 159 | ||
162 | /* Note : once we are there, there is not much you want to do | 160 | /* Note : once we are there, there is not much you want to do |
163 | * with the socket anymore, apart from closing it. | 161 | * with the socket anymore, apart from closing it. |
@@ -220,7 +218,7 @@ static void irda_connect_confirm(void *instance, void *sap, | |||
220 | break; | 218 | break; |
221 | default: | 219 | default: |
222 | self->max_data_size = irttp_get_max_seg_size(self->tsap); | 220 | self->max_data_size = irttp_get_max_seg_size(self->tsap); |
223 | }; | 221 | } |
224 | 222 | ||
225 | IRDA_DEBUG(2, "%s(), max_data_size=%d\n", __FUNCTION__, | 223 | IRDA_DEBUG(2, "%s(), max_data_size=%d\n", __FUNCTION__, |
226 | self->max_data_size); | 224 | self->max_data_size); |
@@ -283,7 +281,7 @@ static void irda_connect_indication(void *instance, void *sap, | |||
283 | break; | 281 | break; |
284 | default: | 282 | default: |
285 | self->max_data_size = irttp_get_max_seg_size(self->tsap); | 283 | self->max_data_size = irttp_get_max_seg_size(self->tsap); |
286 | }; | 284 | } |
287 | 285 | ||
288 | IRDA_DEBUG(2, "%s(), max_data_size=%d\n", __FUNCTION__, | 286 | IRDA_DEBUG(2, "%s(), max_data_size=%d\n", __FUNCTION__, |
289 | self->max_data_size); | 287 | self->max_data_size); |
@@ -306,8 +304,6 @@ static void irda_connect_response(struct irda_sock *self) | |||
306 | 304 | ||
307 | IRDA_DEBUG(2, "%s()\n", __FUNCTION__); | 305 | IRDA_DEBUG(2, "%s()\n", __FUNCTION__); |
308 | 306 | ||
309 | IRDA_ASSERT(self != NULL, return;); | ||
310 | |||
311 | skb = alloc_skb(TTP_MAX_HEADER + TTP_SAR_HEADER, | 307 | skb = alloc_skb(TTP_MAX_HEADER + TTP_SAR_HEADER, |
312 | GFP_ATOMIC); | 308 | GFP_ATOMIC); |
313 | if (skb == NULL) { | 309 | if (skb == NULL) { |
@@ -337,7 +333,7 @@ static void irda_flow_indication(void *instance, void *sap, LOCAL_FLOW flow) | |||
337 | 333 | ||
338 | self = instance; | 334 | self = instance; |
339 | sk = instance; | 335 | sk = instance; |
340 | IRDA_ASSERT(sk != NULL, return;); | 336 | BUG_ON(sk == NULL); |
341 | 337 | ||
342 | switch (flow) { | 338 | switch (flow) { |
343 | case FLOW_STOP: | 339 | case FLOW_STOP: |
@@ -449,7 +445,7 @@ static void irda_discovery_timeout(u_long priv) | |||
449 | IRDA_DEBUG(2, "%s()\n", __FUNCTION__); | 445 | IRDA_DEBUG(2, "%s()\n", __FUNCTION__); |
450 | 446 | ||
451 | self = (struct irda_sock *) priv; | 447 | self = (struct irda_sock *) priv; |
452 | IRDA_ASSERT(self != NULL, return;); | 448 | BUG_ON(self == NULL); |
453 | 449 | ||
454 | /* Nothing for the caller */ | 450 | /* Nothing for the caller */ |
455 | self->cachelog = NULL; | 451 | self->cachelog = NULL; |
@@ -546,8 +542,6 @@ static int irda_find_lsap_sel(struct irda_sock *self, char *name) | |||
546 | { | 542 | { |
547 | IRDA_DEBUG(2, "%s(%p, %s)\n", __FUNCTION__, self, name); | 543 | IRDA_DEBUG(2, "%s(%p, %s)\n", __FUNCTION__, self, name); |
548 | 544 | ||
549 | IRDA_ASSERT(self != NULL, return -1;); | ||
550 | |||
551 | if (self->iriap) { | 545 | if (self->iriap) { |
552 | IRDA_WARNING("%s(): busy with a previous query\n", | 546 | IRDA_WARNING("%s(): busy with a previous query\n", |
553 | __FUNCTION__); | 547 | __FUNCTION__); |
@@ -635,8 +629,6 @@ static int irda_discover_daddr_and_lsap_sel(struct irda_sock *self, char *name) | |||
635 | 629 | ||
636 | IRDA_DEBUG(2, "%s(), name=%s\n", __FUNCTION__, name); | 630 | IRDA_DEBUG(2, "%s(), name=%s\n", __FUNCTION__, name); |
637 | 631 | ||
638 | IRDA_ASSERT(self != NULL, return -1;); | ||
639 | |||
640 | /* Ask lmp for the current discovery log | 632 | /* Ask lmp for the current discovery log |
641 | * Note : we have to use irlmp_get_discoveries(), as opposed | 633 | * Note : we have to use irlmp_get_discoveries(), as opposed |
642 | * to play with the cachelog directly, because while we are | 634 | * to play with the cachelog directly, because while we are |
@@ -784,8 +776,6 @@ static int irda_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
784 | struct irda_sock *self = irda_sk(sk); | 776 | struct irda_sock *self = irda_sk(sk); |
785 | int err; | 777 | int err; |
786 | 778 | ||
787 | IRDA_ASSERT(self != NULL, return -1;); | ||
788 | |||
789 | IRDA_DEBUG(2, "%s(%p)\n", __FUNCTION__, self); | 779 | IRDA_DEBUG(2, "%s(%p)\n", __FUNCTION__, self); |
790 | 780 | ||
791 | if (addr_len != sizeof(struct sockaddr_irda)) | 781 | if (addr_len != sizeof(struct sockaddr_irda)) |
@@ -841,8 +831,6 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags) | |||
841 | 831 | ||
842 | IRDA_DEBUG(2, "%s()\n", __FUNCTION__); | 832 | IRDA_DEBUG(2, "%s()\n", __FUNCTION__); |
843 | 833 | ||
844 | IRDA_ASSERT(self != NULL, return -1;); | ||
845 | |||
846 | err = irda_create(newsock, sk->sk_protocol); | 834 | err = irda_create(newsock, sk->sk_protocol); |
847 | if (err) | 835 | if (err) |
848 | return err; | 836 | return err; |
@@ -873,44 +861,28 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags) | |||
873 | * calling us, the data is waiting for us ;-) | 861 | * calling us, the data is waiting for us ;-) |
874 | * Jean II | 862 | * Jean II |
875 | */ | 863 | */ |
876 | skb = skb_dequeue(&sk->sk_receive_queue); | 864 | while (1) { |
877 | if (skb == NULL) { | 865 | skb = skb_dequeue(&sk->sk_receive_queue); |
878 | int ret = 0; | 866 | if (skb) |
879 | DECLARE_WAITQUEUE(waitq, current); | 867 | break; |
880 | 868 | ||
881 | /* Non blocking operation */ | 869 | /* Non blocking operation */ |
882 | if (flags & O_NONBLOCK) | 870 | if (flags & O_NONBLOCK) |
883 | return -EWOULDBLOCK; | 871 | return -EWOULDBLOCK; |
884 | 872 | ||
885 | /* The following code is a cut'n'paste of the | 873 | err = wait_event_interruptible(*(sk->sk_sleep), |
886 | * wait_event_interruptible() macro. | 874 | skb_peek(&sk->sk_receive_queue)); |
887 | * We don't us the macro because the condition has | 875 | if (err) |
888 | * side effects : we want to make sure that only one | 876 | return err; |
889 | * skb get dequeued - Jean II */ | ||
890 | add_wait_queue(sk->sk_sleep, &waitq); | ||
891 | for (;;) { | ||
892 | set_current_state(TASK_INTERRUPTIBLE); | ||
893 | skb = skb_dequeue(&sk->sk_receive_queue); | ||
894 | if (skb != NULL) | ||
895 | break; | ||
896 | if (!signal_pending(current)) { | ||
897 | schedule(); | ||
898 | continue; | ||
899 | } | ||
900 | ret = -ERESTARTSYS; | ||
901 | break; | ||
902 | } | ||
903 | current->state = TASK_RUNNING; | ||
904 | remove_wait_queue(sk->sk_sleep, &waitq); | ||
905 | if(ret) | ||
906 | return -ERESTARTSYS; | ||
907 | } | 877 | } |
908 | 878 | ||
909 | newsk = newsock->sk; | 879 | newsk = newsock->sk; |
880 | if (newsk == NULL) | ||
881 | return -EIO; | ||
882 | |||
910 | newsk->sk_state = TCP_ESTABLISHED; | 883 | newsk->sk_state = TCP_ESTABLISHED; |
911 | 884 | ||
912 | new = irda_sk(newsk); | 885 | new = irda_sk(newsk); |
913 | IRDA_ASSERT(new != NULL, return -1;); | ||
914 | 886 | ||
915 | /* Now attach up the new socket */ | 887 | /* Now attach up the new socket */ |
916 | new->tsap = irttp_dup(self->tsap, new); | 888 | new->tsap = irttp_dup(self->tsap, new); |
@@ -1061,7 +1033,8 @@ static int irda_connect(struct socket *sock, struct sockaddr *uaddr, | |||
1061 | 1033 | ||
1062 | if (sk->sk_state != TCP_ESTABLISHED) { | 1034 | if (sk->sk_state != TCP_ESTABLISHED) { |
1063 | sock->state = SS_UNCONNECTED; | 1035 | sock->state = SS_UNCONNECTED; |
1064 | return sock_error(sk); /* Always set at this point */ | 1036 | err = sock_error(sk); |
1037 | return err? err : -ECONNRESET; | ||
1065 | } | 1038 | } |
1066 | 1039 | ||
1067 | sock->state = SS_CONNECTED; | 1040 | sock->state = SS_CONNECTED; |
@@ -1171,8 +1144,6 @@ static void irda_destroy_socket(struct irda_sock *self) | |||
1171 | { | 1144 | { |
1172 | IRDA_DEBUG(2, "%s(%p)\n", __FUNCTION__, self); | 1145 | IRDA_DEBUG(2, "%s(%p)\n", __FUNCTION__, self); |
1173 | 1146 | ||
1174 | IRDA_ASSERT(self != NULL, return;); | ||
1175 | |||
1176 | /* Unregister with IrLMP */ | 1147 | /* Unregister with IrLMP */ |
1177 | irlmp_unregister_client(self->ckey); | 1148 | irlmp_unregister_client(self->ckey); |
1178 | irlmp_unregister_service(self->skey); | 1149 | irlmp_unregister_service(self->skey); |
@@ -1274,7 +1245,6 @@ static int irda_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
1274 | struct sock *sk = sock->sk; | 1245 | struct sock *sk = sock->sk; |
1275 | struct irda_sock *self; | 1246 | struct irda_sock *self; |
1276 | struct sk_buff *skb; | 1247 | struct sk_buff *skb; |
1277 | unsigned char *asmptr; | ||
1278 | int err; | 1248 | int err; |
1279 | 1249 | ||
1280 | IRDA_DEBUG(4, "%s(), len=%zd\n", __FUNCTION__, len); | 1250 | IRDA_DEBUG(4, "%s(), len=%zd\n", __FUNCTION__, len); |
@@ -1292,7 +1262,6 @@ static int irda_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
1292 | return -ENOTCONN; | 1262 | return -ENOTCONN; |
1293 | 1263 | ||
1294 | self = irda_sk(sk); | 1264 | self = irda_sk(sk); |
1295 | IRDA_ASSERT(self != NULL, return -1;); | ||
1296 | 1265 | ||
1297 | /* Check if IrTTP is wants us to slow down */ | 1266 | /* Check if IrTTP is wants us to slow down */ |
1298 | 1267 | ||
@@ -1317,9 +1286,9 @@ static int irda_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
1317 | return -ENOBUFS; | 1286 | return -ENOBUFS; |
1318 | 1287 | ||
1319 | skb_reserve(skb, self->max_header_size + 16); | 1288 | skb_reserve(skb, self->max_header_size + 16); |
1320 | 1289 | skb_reset_transport_header(skb); | |
1321 | asmptr = skb->h.raw = skb_put(skb, len); | 1290 | skb_put(skb, len); |
1322 | err = memcpy_fromiovec(asmptr, msg->msg_iov, len); | 1291 | err = memcpy_fromiovec(skb_transport_header(skb), msg->msg_iov, len); |
1323 | if (err) { | 1292 | if (err) { |
1324 | kfree_skb(skb); | 1293 | kfree_skb(skb); |
1325 | return err; | 1294 | return err; |
@@ -1355,16 +1324,16 @@ static int irda_recvmsg_dgram(struct kiocb *iocb, struct socket *sock, | |||
1355 | 1324 | ||
1356 | IRDA_DEBUG(4, "%s()\n", __FUNCTION__); | 1325 | IRDA_DEBUG(4, "%s()\n", __FUNCTION__); |
1357 | 1326 | ||
1358 | IRDA_ASSERT(self != NULL, return -1;); | 1327 | if ((err = sock_error(sk)) < 0) |
1359 | IRDA_ASSERT(!sock_error(sk), return -1;); | 1328 | return err; |
1360 | 1329 | ||
1361 | skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, | 1330 | skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, |
1362 | flags & MSG_DONTWAIT, &err); | 1331 | flags & MSG_DONTWAIT, &err); |
1363 | if (!skb) | 1332 | if (!skb) |
1364 | return err; | 1333 | return err; |
1365 | 1334 | ||
1366 | skb->h.raw = skb->data; | 1335 | skb_reset_transport_header(skb); |
1367 | copied = skb->len; | 1336 | copied = skb->len; |
1368 | 1337 | ||
1369 | if (copied > size) { | 1338 | if (copied > size) { |
1370 | IRDA_DEBUG(2, "%s(), Received truncated frame (%zd < %zd)!\n", | 1339 | IRDA_DEBUG(2, "%s(), Received truncated frame (%zd < %zd)!\n", |
@@ -1403,13 +1372,13 @@ static int irda_recvmsg_stream(struct kiocb *iocb, struct socket *sock, | |||
1403 | struct irda_sock *self = irda_sk(sk); | 1372 | struct irda_sock *self = irda_sk(sk); |
1404 | int noblock = flags & MSG_DONTWAIT; | 1373 | int noblock = flags & MSG_DONTWAIT; |
1405 | size_t copied = 0; | 1374 | size_t copied = 0; |
1406 | int target = 1; | 1375 | int target, err; |
1407 | DECLARE_WAITQUEUE(waitq, current); | 1376 | long timeo; |
1408 | 1377 | ||
1409 | IRDA_DEBUG(3, "%s()\n", __FUNCTION__); | 1378 | IRDA_DEBUG(3, "%s()\n", __FUNCTION__); |
1410 | 1379 | ||
1411 | IRDA_ASSERT(self != NULL, return -1;); | 1380 | if ((err = sock_error(sk)) < 0) |
1412 | IRDA_ASSERT(!sock_error(sk), return -1;); | 1381 | return err; |
1413 | 1382 | ||
1414 | if (sock->flags & __SO_ACCEPTCON) | 1383 | if (sock->flags & __SO_ACCEPTCON) |
1415 | return(-EINVAL); | 1384 | return(-EINVAL); |
@@ -1417,8 +1386,8 @@ static int irda_recvmsg_stream(struct kiocb *iocb, struct socket *sock, | |||
1417 | if (flags & MSG_OOB) | 1386 | if (flags & MSG_OOB) |
1418 | return -EOPNOTSUPP; | 1387 | return -EOPNOTSUPP; |
1419 | 1388 | ||
1420 | if (flags & MSG_WAITALL) | 1389 | target = sock_rcvlowat(sk, flags & MSG_WAITALL, size); |
1421 | target = size; | 1390 | timeo = sock_rcvtimeo(sk, noblock); |
1422 | 1391 | ||
1423 | msg->msg_namelen = 0; | 1392 | msg->msg_namelen = 0; |
1424 | 1393 | ||
@@ -1426,19 +1395,14 @@ static int irda_recvmsg_stream(struct kiocb *iocb, struct socket *sock, | |||
1426 | int chunk; | 1395 | int chunk; |
1427 | struct sk_buff *skb = skb_dequeue(&sk->sk_receive_queue); | 1396 | struct sk_buff *skb = skb_dequeue(&sk->sk_receive_queue); |
1428 | 1397 | ||
1429 | if (skb==NULL) { | 1398 | if (skb == NULL) { |
1399 | DEFINE_WAIT(wait); | ||
1430 | int ret = 0; | 1400 | int ret = 0; |
1431 | 1401 | ||
1432 | if (copied >= target) | 1402 | if (copied >= target) |
1433 | break; | 1403 | break; |
1434 | 1404 | ||
1435 | /* The following code is a cut'n'paste of the | 1405 | prepare_to_wait_exclusive(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); |
1436 | * wait_event_interruptible() macro. | ||
1437 | * We don't us the macro because the test condition | ||
1438 | * is messy. - Jean II */ | ||
1439 | set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); | ||
1440 | add_wait_queue(sk->sk_sleep, &waitq); | ||
1441 | set_current_state(TASK_INTERRUPTIBLE); | ||
1442 | 1406 | ||
1443 | /* | 1407 | /* |
1444 | * POSIX 1003.1g mandates this order. | 1408 | * POSIX 1003.1g mandates this order. |
@@ -1451,17 +1415,17 @@ static int irda_recvmsg_stream(struct kiocb *iocb, struct socket *sock, | |||
1451 | else if (noblock) | 1415 | else if (noblock) |
1452 | ret = -EAGAIN; | 1416 | ret = -EAGAIN; |
1453 | else if (signal_pending(current)) | 1417 | else if (signal_pending(current)) |
1454 | ret = -ERESTARTSYS; | 1418 | ret = sock_intr_errno(timeo); |
1419 | else if (sk->sk_state != TCP_ESTABLISHED) | ||
1420 | ret = -ENOTCONN; | ||
1455 | else if (skb_peek(&sk->sk_receive_queue) == NULL) | 1421 | else if (skb_peek(&sk->sk_receive_queue) == NULL) |
1456 | /* Wait process until data arrives */ | 1422 | /* Wait process until data arrives */ |
1457 | schedule(); | 1423 | schedule(); |
1458 | 1424 | ||
1459 | current->state = TASK_RUNNING; | 1425 | finish_wait(sk->sk_sleep, &wait); |
1460 | remove_wait_queue(sk->sk_sleep, &waitq); | ||
1461 | clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); | ||
1462 | 1426 | ||
1463 | if(ret) | 1427 | if (ret) |
1464 | return(ret); | 1428 | return ret; |
1465 | if (sk->sk_shutdown & RCV_SHUTDOWN) | 1429 | if (sk->sk_shutdown & RCV_SHUTDOWN) |
1466 | break; | 1430 | break; |
1467 | 1431 | ||
@@ -1530,7 +1494,6 @@ static int irda_sendmsg_dgram(struct kiocb *iocb, struct socket *sock, | |||
1530 | struct sock *sk = sock->sk; | 1494 | struct sock *sk = sock->sk; |
1531 | struct irda_sock *self; | 1495 | struct irda_sock *self; |
1532 | struct sk_buff *skb; | 1496 | struct sk_buff *skb; |
1533 | unsigned char *asmptr; | ||
1534 | int err; | 1497 | int err; |
1535 | 1498 | ||
1536 | IRDA_DEBUG(4, "%s(), len=%zd\n", __FUNCTION__, len); | 1499 | IRDA_DEBUG(4, "%s(), len=%zd\n", __FUNCTION__, len); |
@@ -1547,7 +1510,6 @@ static int irda_sendmsg_dgram(struct kiocb *iocb, struct socket *sock, | |||
1547 | return -ENOTCONN; | 1510 | return -ENOTCONN; |
1548 | 1511 | ||
1549 | self = irda_sk(sk); | 1512 | self = irda_sk(sk); |
1550 | IRDA_ASSERT(self != NULL, return -1;); | ||
1551 | 1513 | ||
1552 | /* | 1514 | /* |
1553 | * Check that we don't send out too big frames. This is an unreliable | 1515 | * Check that we don't send out too big frames. This is an unreliable |
@@ -1566,10 +1528,11 @@ static int irda_sendmsg_dgram(struct kiocb *iocb, struct socket *sock, | |||
1566 | return -ENOBUFS; | 1528 | return -ENOBUFS; |
1567 | 1529 | ||
1568 | skb_reserve(skb, self->max_header_size); | 1530 | skb_reserve(skb, self->max_header_size); |
1531 | skb_reset_transport_header(skb); | ||
1569 | 1532 | ||
1570 | IRDA_DEBUG(4, "%s(), appending user data\n", __FUNCTION__); | 1533 | IRDA_DEBUG(4, "%s(), appending user data\n", __FUNCTION__); |
1571 | asmptr = skb->h.raw = skb_put(skb, len); | 1534 | skb_put(skb, len); |
1572 | err = memcpy_fromiovec(asmptr, msg->msg_iov, len); | 1535 | err = memcpy_fromiovec(skb_transport_header(skb), msg->msg_iov, len); |
1573 | if (err) { | 1536 | if (err) { |
1574 | kfree_skb(skb); | 1537 | kfree_skb(skb); |
1575 | return err; | 1538 | return err; |
@@ -1602,7 +1565,6 @@ static int irda_sendmsg_ultra(struct kiocb *iocb, struct socket *sock, | |||
1602 | __u8 pid = 0; | 1565 | __u8 pid = 0; |
1603 | int bound = 0; | 1566 | int bound = 0; |
1604 | struct sk_buff *skb; | 1567 | struct sk_buff *skb; |
1605 | unsigned char *asmptr; | ||
1606 | int err; | 1568 | int err; |
1607 | 1569 | ||
1608 | IRDA_DEBUG(4, "%s(), len=%zd\n", __FUNCTION__, len); | 1570 | IRDA_DEBUG(4, "%s(), len=%zd\n", __FUNCTION__, len); |
@@ -1616,7 +1578,6 @@ static int irda_sendmsg_ultra(struct kiocb *iocb, struct socket *sock, | |||
1616 | } | 1578 | } |
1617 | 1579 | ||
1618 | self = irda_sk(sk); | 1580 | self = irda_sk(sk); |
1619 | IRDA_ASSERT(self != NULL, return -1;); | ||
1620 | 1581 | ||
1621 | /* Check if an address was specified with sendto. Jean II */ | 1582 | /* Check if an address was specified with sendto. Jean II */ |
1622 | if (msg->msg_name) { | 1583 | if (msg->msg_name) { |
@@ -1662,10 +1623,11 @@ static int irda_sendmsg_ultra(struct kiocb *iocb, struct socket *sock, | |||
1662 | return -ENOBUFS; | 1623 | return -ENOBUFS; |
1663 | 1624 | ||
1664 | skb_reserve(skb, self->max_header_size); | 1625 | skb_reserve(skb, self->max_header_size); |
1626 | skb_reset_transport_header(skb); | ||
1665 | 1627 | ||
1666 | IRDA_DEBUG(4, "%s(), appending user data\n", __FUNCTION__); | 1628 | IRDA_DEBUG(4, "%s(), appending user data\n", __FUNCTION__); |
1667 | asmptr = skb->h.raw = skb_put(skb, len); | 1629 | skb_put(skb, len); |
1668 | err = memcpy_fromiovec(asmptr, msg->msg_iov, len); | 1630 | err = memcpy_fromiovec(skb_transport_header(skb), msg->msg_iov, len); |
1669 | if (err) { | 1631 | if (err) { |
1670 | kfree_skb(skb); | 1632 | kfree_skb(skb); |
1671 | return err; | 1633 | return err; |
@@ -1689,8 +1651,6 @@ static int irda_shutdown(struct socket *sock, int how) | |||
1689 | struct sock *sk = sock->sk; | 1651 | struct sock *sk = sock->sk; |
1690 | struct irda_sock *self = irda_sk(sk); | 1652 | struct irda_sock *self = irda_sk(sk); |
1691 | 1653 | ||
1692 | IRDA_ASSERT(self != NULL, return -1;); | ||
1693 | |||
1694 | IRDA_DEBUG(1, "%s(%p)\n", __FUNCTION__, self); | 1654 | IRDA_DEBUG(1, "%s(%p)\n", __FUNCTION__, self); |
1695 | 1655 | ||
1696 | sk->sk_state = TCP_CLOSE; | 1656 | sk->sk_state = TCP_CLOSE; |
@@ -1863,8 +1823,6 @@ static int irda_setsockopt(struct socket *sock, int level, int optname, | |||
1863 | struct ias_attrib * ias_attr; /* Attribute in IAS object */ | 1823 | struct ias_attrib * ias_attr; /* Attribute in IAS object */ |
1864 | int opt; | 1824 | int opt; |
1865 | 1825 | ||
1866 | IRDA_ASSERT(self != NULL, return -1;); | ||
1867 | |||
1868 | IRDA_DEBUG(2, "%s(%p)\n", __FUNCTION__, self); | 1826 | IRDA_DEBUG(2, "%s(%p)\n", __FUNCTION__, self); |
1869 | 1827 | ||
1870 | if (level != SOL_IRLMP) | 1828 | if (level != SOL_IRLMP) |