diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /net/irda | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'net/irda')
30 files changed, 364 insertions, 322 deletions
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c index fd55b5135de5..cc616974a447 100644 --- a/net/irda/af_irda.c +++ b/net/irda/af_irda.c | |||
@@ -45,7 +45,6 @@ | |||
45 | #include <linux/capability.h> | 45 | #include <linux/capability.h> |
46 | #include <linux/module.h> | 46 | #include <linux/module.h> |
47 | #include <linux/types.h> | 47 | #include <linux/types.h> |
48 | #include <linux/smp_lock.h> | ||
49 | #include <linux/socket.h> | 48 | #include <linux/socket.h> |
50 | #include <linux/sockios.h> | 49 | #include <linux/sockios.h> |
51 | #include <linux/slab.h> | 50 | #include <linux/slab.h> |
@@ -573,9 +572,9 @@ static int irda_find_lsap_sel(struct irda_sock *self, char *name) | |||
573 | /* Requested object/attribute doesn't exist */ | 572 | /* Requested object/attribute doesn't exist */ |
574 | if((self->errno == IAS_CLASS_UNKNOWN) || | 573 | if((self->errno == IAS_CLASS_UNKNOWN) || |
575 | (self->errno == IAS_ATTRIB_UNKNOWN)) | 574 | (self->errno == IAS_ATTRIB_UNKNOWN)) |
576 | return (-EADDRNOTAVAIL); | 575 | return -EADDRNOTAVAIL; |
577 | else | 576 | else |
578 | return (-EHOSTUNREACH); | 577 | return -EHOSTUNREACH; |
579 | } | 578 | } |
580 | 579 | ||
581 | /* Get the remote TSAP selector */ | 580 | /* Get the remote TSAP selector */ |
@@ -663,7 +662,7 @@ static int irda_discover_daddr_and_lsap_sel(struct irda_sock *self, char *name) | |||
663 | __func__, name); | 662 | __func__, name); |
664 | self->daddr = DEV_ADDR_ANY; | 663 | self->daddr = DEV_ADDR_ANY; |
665 | kfree(discoveries); | 664 | kfree(discoveries); |
666 | return(-ENOTUNIQ); | 665 | return -ENOTUNIQ; |
667 | } | 666 | } |
668 | /* First time we found that one, save it ! */ | 667 | /* First time we found that one, save it ! */ |
669 | daddr = self->daddr; | 668 | daddr = self->daddr; |
@@ -677,7 +676,7 @@ static int irda_discover_daddr_and_lsap_sel(struct irda_sock *self, char *name) | |||
677 | IRDA_DEBUG(0, "%s(), unexpected IAS query failure\n", __func__); | 676 | IRDA_DEBUG(0, "%s(), unexpected IAS query failure\n", __func__); |
678 | self->daddr = DEV_ADDR_ANY; | 677 | self->daddr = DEV_ADDR_ANY; |
679 | kfree(discoveries); | 678 | kfree(discoveries); |
680 | return(-EHOSTUNREACH); | 679 | return -EHOSTUNREACH; |
681 | break; | 680 | break; |
682 | } | 681 | } |
683 | } | 682 | } |
@@ -689,7 +688,7 @@ static int irda_discover_daddr_and_lsap_sel(struct irda_sock *self, char *name) | |||
689 | IRDA_DEBUG(1, "%s(), cannot discover service ''%s'' in any device !!!\n", | 688 | IRDA_DEBUG(1, "%s(), cannot discover service ''%s'' in any device !!!\n", |
690 | __func__, name); | 689 | __func__, name); |
691 | self->daddr = DEV_ADDR_ANY; | 690 | self->daddr = DEV_ADDR_ANY; |
692 | return(-EADDRNOTAVAIL); | 691 | return -EADDRNOTAVAIL; |
693 | } | 692 | } |
694 | 693 | ||
695 | /* Revert back to discovered device & service */ | 694 | /* Revert back to discovered device & service */ |
@@ -715,14 +714,11 @@ static int irda_getname(struct socket *sock, struct sockaddr *uaddr, | |||
715 | struct sockaddr_irda saddr; | 714 | struct sockaddr_irda saddr; |
716 | struct sock *sk = sock->sk; | 715 | struct sock *sk = sock->sk; |
717 | struct irda_sock *self = irda_sk(sk); | 716 | struct irda_sock *self = irda_sk(sk); |
718 | int err; | ||
719 | 717 | ||
720 | lock_kernel(); | ||
721 | memset(&saddr, 0, sizeof(saddr)); | 718 | memset(&saddr, 0, sizeof(saddr)); |
722 | if (peer) { | 719 | if (peer) { |
723 | err = -ENOTCONN; | ||
724 | if (sk->sk_state != TCP_ESTABLISHED) | 720 | if (sk->sk_state != TCP_ESTABLISHED) |
725 | goto out; | 721 | return -ENOTCONN; |
726 | 722 | ||
727 | saddr.sir_family = AF_IRDA; | 723 | saddr.sir_family = AF_IRDA; |
728 | saddr.sir_lsap_sel = self->dtsap_sel; | 724 | saddr.sir_lsap_sel = self->dtsap_sel; |
@@ -739,10 +735,8 @@ static int irda_getname(struct socket *sock, struct sockaddr *uaddr, | |||
739 | /* uaddr_len come to us uninitialised */ | 735 | /* uaddr_len come to us uninitialised */ |
740 | *uaddr_len = sizeof (struct sockaddr_irda); | 736 | *uaddr_len = sizeof (struct sockaddr_irda); |
741 | memcpy(uaddr, &saddr, *uaddr_len); | 737 | memcpy(uaddr, &saddr, *uaddr_len); |
742 | err = 0; | 738 | |
743 | out: | 739 | return 0; |
744 | unlock_kernel(); | ||
745 | return err; | ||
746 | } | 740 | } |
747 | 741 | ||
748 | /* | 742 | /* |
@@ -758,7 +752,8 @@ static int irda_listen(struct socket *sock, int backlog) | |||
758 | 752 | ||
759 | IRDA_DEBUG(2, "%s()\n", __func__); | 753 | IRDA_DEBUG(2, "%s()\n", __func__); |
760 | 754 | ||
761 | lock_kernel(); | 755 | lock_sock(sk); |
756 | |||
762 | if ((sk->sk_type != SOCK_STREAM) && (sk->sk_type != SOCK_SEQPACKET) && | 757 | if ((sk->sk_type != SOCK_STREAM) && (sk->sk_type != SOCK_SEQPACKET) && |
763 | (sk->sk_type != SOCK_DGRAM)) | 758 | (sk->sk_type != SOCK_DGRAM)) |
764 | goto out; | 759 | goto out; |
@@ -770,7 +765,7 @@ static int irda_listen(struct socket *sock, int backlog) | |||
770 | err = 0; | 765 | err = 0; |
771 | } | 766 | } |
772 | out: | 767 | out: |
773 | unlock_kernel(); | 768 | release_sock(sk); |
774 | 769 | ||
775 | return err; | 770 | return err; |
776 | } | 771 | } |
@@ -793,7 +788,7 @@ static int irda_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
793 | if (addr_len != sizeof(struct sockaddr_irda)) | 788 | if (addr_len != sizeof(struct sockaddr_irda)) |
794 | return -EINVAL; | 789 | return -EINVAL; |
795 | 790 | ||
796 | lock_kernel(); | 791 | lock_sock(sk); |
797 | #ifdef CONFIG_IRDA_ULTRA | 792 | #ifdef CONFIG_IRDA_ULTRA |
798 | /* Special care for Ultra sockets */ | 793 | /* Special care for Ultra sockets */ |
799 | if ((sk->sk_type == SOCK_DGRAM) && | 794 | if ((sk->sk_type == SOCK_DGRAM) && |
@@ -836,7 +831,7 @@ static int irda_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
836 | 831 | ||
837 | err = 0; | 832 | err = 0; |
838 | out: | 833 | out: |
839 | unlock_kernel(); | 834 | release_sock(sk); |
840 | return err; | 835 | return err; |
841 | } | 836 | } |
842 | 837 | ||
@@ -856,12 +851,13 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags) | |||
856 | 851 | ||
857 | IRDA_DEBUG(2, "%s()\n", __func__); | 852 | IRDA_DEBUG(2, "%s()\n", __func__); |
858 | 853 | ||
859 | lock_kernel(); | ||
860 | err = irda_create(sock_net(sk), newsock, sk->sk_protocol, 0); | 854 | err = irda_create(sock_net(sk), newsock, sk->sk_protocol, 0); |
861 | if (err) | 855 | if (err) |
862 | goto out; | 856 | return err; |
863 | 857 | ||
864 | err = -EINVAL; | 858 | err = -EINVAL; |
859 | |||
860 | lock_sock(sk); | ||
865 | if (sock->state != SS_UNCONNECTED) | 861 | if (sock->state != SS_UNCONNECTED) |
866 | goto out; | 862 | goto out; |
867 | 863 | ||
@@ -947,7 +943,7 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags) | |||
947 | irda_connect_response(new); | 943 | irda_connect_response(new); |
948 | err = 0; | 944 | err = 0; |
949 | out: | 945 | out: |
950 | unlock_kernel(); | 946 | release_sock(sk); |
951 | return err; | 947 | return err; |
952 | } | 948 | } |
953 | 949 | ||
@@ -981,7 +977,7 @@ static int irda_connect(struct socket *sock, struct sockaddr *uaddr, | |||
981 | 977 | ||
982 | IRDA_DEBUG(2, "%s(%p)\n", __func__, self); | 978 | IRDA_DEBUG(2, "%s(%p)\n", __func__, self); |
983 | 979 | ||
984 | lock_kernel(); | 980 | lock_sock(sk); |
985 | /* Don't allow connect for Ultra sockets */ | 981 | /* Don't allow connect for Ultra sockets */ |
986 | err = -ESOCKTNOSUPPORT; | 982 | err = -ESOCKTNOSUPPORT; |
987 | if ((sk->sk_type == SOCK_DGRAM) && (sk->sk_protocol == IRDAPROTO_ULTRA)) | 983 | if ((sk->sk_type == SOCK_DGRAM) && (sk->sk_protocol == IRDAPROTO_ULTRA)) |
@@ -1072,6 +1068,8 @@ static int irda_connect(struct socket *sock, struct sockaddr *uaddr, | |||
1072 | 1068 | ||
1073 | if (sk->sk_state != TCP_ESTABLISHED) { | 1069 | if (sk->sk_state != TCP_ESTABLISHED) { |
1074 | sock->state = SS_UNCONNECTED; | 1070 | sock->state = SS_UNCONNECTED; |
1071 | if (sk->sk_prot->disconnect(sk, flags)) | ||
1072 | sock->state = SS_DISCONNECTING; | ||
1075 | err = sock_error(sk); | 1073 | err = sock_error(sk); |
1076 | if (!err) | 1074 | if (!err) |
1077 | err = -ECONNRESET; | 1075 | err = -ECONNRESET; |
@@ -1084,7 +1082,7 @@ static int irda_connect(struct socket *sock, struct sockaddr *uaddr, | |||
1084 | self->saddr = irttp_get_saddr(self->tsap); | 1082 | self->saddr = irttp_get_saddr(self->tsap); |
1085 | err = 0; | 1083 | err = 0; |
1086 | out: | 1084 | out: |
1087 | unlock_kernel(); | 1085 | release_sock(sk); |
1088 | return err; | 1086 | return err; |
1089 | } | 1087 | } |
1090 | 1088 | ||
@@ -1231,7 +1229,6 @@ static int irda_release(struct socket *sock) | |||
1231 | if (sk == NULL) | 1229 | if (sk == NULL) |
1232 | return 0; | 1230 | return 0; |
1233 | 1231 | ||
1234 | lock_kernel(); | ||
1235 | lock_sock(sk); | 1232 | lock_sock(sk); |
1236 | sk->sk_state = TCP_CLOSE; | 1233 | sk->sk_state = TCP_CLOSE; |
1237 | sk->sk_shutdown |= SEND_SHUTDOWN; | 1234 | sk->sk_shutdown |= SEND_SHUTDOWN; |
@@ -1250,7 +1247,6 @@ static int irda_release(struct socket *sock) | |||
1250 | /* Destroy networking socket if we are the last reference on it, | 1247 | /* Destroy networking socket if we are the last reference on it, |
1251 | * i.e. if(sk->sk_refcnt == 0) -> sk_free(sk) */ | 1248 | * i.e. if(sk->sk_refcnt == 0) -> sk_free(sk) */ |
1252 | sock_put(sk); | 1249 | sock_put(sk); |
1253 | unlock_kernel(); | ||
1254 | 1250 | ||
1255 | /* Notes on socket locking and deallocation... - Jean II | 1251 | /* Notes on socket locking and deallocation... - Jean II |
1256 | * In theory we should put pairs of sock_hold() / sock_put() to | 1252 | * In theory we should put pairs of sock_hold() / sock_put() to |
@@ -1298,14 +1294,14 @@ static int irda_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
1298 | 1294 | ||
1299 | IRDA_DEBUG(4, "%s(), len=%zd\n", __func__, len); | 1295 | IRDA_DEBUG(4, "%s(), len=%zd\n", __func__, len); |
1300 | 1296 | ||
1301 | lock_kernel(); | ||
1302 | /* Note : socket.c set MSG_EOR on SEQPACKET sockets */ | 1297 | /* Note : socket.c set MSG_EOR on SEQPACKET sockets */ |
1303 | if (msg->msg_flags & ~(MSG_DONTWAIT | MSG_EOR | MSG_CMSG_COMPAT | | 1298 | if (msg->msg_flags & ~(MSG_DONTWAIT | MSG_EOR | MSG_CMSG_COMPAT | |
1304 | MSG_NOSIGNAL)) { | 1299 | MSG_NOSIGNAL)) { |
1305 | err = -EINVAL; | 1300 | return -EINVAL; |
1306 | goto out; | ||
1307 | } | 1301 | } |
1308 | 1302 | ||
1303 | lock_sock(sk); | ||
1304 | |||
1309 | if (sk->sk_shutdown & SEND_SHUTDOWN) | 1305 | if (sk->sk_shutdown & SEND_SHUTDOWN) |
1310 | goto out_err; | 1306 | goto out_err; |
1311 | 1307 | ||
@@ -1361,14 +1357,14 @@ static int irda_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
1361 | goto out_err; | 1357 | goto out_err; |
1362 | } | 1358 | } |
1363 | 1359 | ||
1364 | unlock_kernel(); | 1360 | release_sock(sk); |
1365 | /* Tell client how much data we actually sent */ | 1361 | /* Tell client how much data we actually sent */ |
1366 | return len; | 1362 | return len; |
1367 | 1363 | ||
1368 | out_err: | 1364 | out_err: |
1369 | err = sk_stream_error(sk, msg->msg_flags, err); | 1365 | err = sk_stream_error(sk, msg->msg_flags, err); |
1370 | out: | 1366 | out: |
1371 | unlock_kernel(); | 1367 | release_sock(sk); |
1372 | return err; | 1368 | return err; |
1373 | 1369 | ||
1374 | } | 1370 | } |
@@ -1390,14 +1386,10 @@ static int irda_recvmsg_dgram(struct kiocb *iocb, struct socket *sock, | |||
1390 | 1386 | ||
1391 | IRDA_DEBUG(4, "%s()\n", __func__); | 1387 | IRDA_DEBUG(4, "%s()\n", __func__); |
1392 | 1388 | ||
1393 | lock_kernel(); | ||
1394 | if ((err = sock_error(sk)) < 0) | ||
1395 | goto out; | ||
1396 | |||
1397 | skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, | 1389 | skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, |
1398 | flags & MSG_DONTWAIT, &err); | 1390 | flags & MSG_DONTWAIT, &err); |
1399 | if (!skb) | 1391 | if (!skb) |
1400 | goto out; | 1392 | return err; |
1401 | 1393 | ||
1402 | skb_reset_transport_header(skb); | 1394 | skb_reset_transport_header(skb); |
1403 | copied = skb->len; | 1395 | copied = skb->len; |
@@ -1425,12 +1417,8 @@ static int irda_recvmsg_dgram(struct kiocb *iocb, struct socket *sock, | |||
1425 | irttp_flow_request(self->tsap, FLOW_START); | 1417 | irttp_flow_request(self->tsap, FLOW_START); |
1426 | } | 1418 | } |
1427 | } | 1419 | } |
1428 | unlock_kernel(); | ||
1429 | return copied; | ||
1430 | 1420 | ||
1431 | out: | 1421 | return copied; |
1432 | unlock_kernel(); | ||
1433 | return err; | ||
1434 | } | 1422 | } |
1435 | 1423 | ||
1436 | /* | 1424 | /* |
@@ -1448,17 +1436,15 @@ static int irda_recvmsg_stream(struct kiocb *iocb, struct socket *sock, | |||
1448 | 1436 | ||
1449 | IRDA_DEBUG(3, "%s()\n", __func__); | 1437 | IRDA_DEBUG(3, "%s()\n", __func__); |
1450 | 1438 | ||
1451 | lock_kernel(); | ||
1452 | if ((err = sock_error(sk)) < 0) | 1439 | if ((err = sock_error(sk)) < 0) |
1453 | goto out; | 1440 | return err; |
1454 | 1441 | ||
1455 | err = -EINVAL; | ||
1456 | if (sock->flags & __SO_ACCEPTCON) | 1442 | if (sock->flags & __SO_ACCEPTCON) |
1457 | goto out; | 1443 | return -EINVAL; |
1458 | 1444 | ||
1459 | err =-EOPNOTSUPP; | 1445 | err =-EOPNOTSUPP; |
1460 | if (flags & MSG_OOB) | 1446 | if (flags & MSG_OOB) |
1461 | goto out; | 1447 | return -EOPNOTSUPP; |
1462 | 1448 | ||
1463 | err = 0; | 1449 | err = 0; |
1464 | target = sock_rcvlowat(sk, flags & MSG_WAITALL, size); | 1450 | target = sock_rcvlowat(sk, flags & MSG_WAITALL, size); |
@@ -1500,7 +1486,7 @@ static int irda_recvmsg_stream(struct kiocb *iocb, struct socket *sock, | |||
1500 | finish_wait(sk_sleep(sk), &wait); | 1486 | finish_wait(sk_sleep(sk), &wait); |
1501 | 1487 | ||
1502 | if (err) | 1488 | if (err) |
1503 | goto out; | 1489 | return err; |
1504 | if (sk->sk_shutdown & RCV_SHUTDOWN) | 1490 | if (sk->sk_shutdown & RCV_SHUTDOWN) |
1505 | break; | 1491 | break; |
1506 | 1492 | ||
@@ -1553,9 +1539,7 @@ static int irda_recvmsg_stream(struct kiocb *iocb, struct socket *sock, | |||
1553 | } | 1539 | } |
1554 | } | 1540 | } |
1555 | 1541 | ||
1556 | out: | 1542 | return copied; |
1557 | unlock_kernel(); | ||
1558 | return err ? : copied; | ||
1559 | } | 1543 | } |
1560 | 1544 | ||
1561 | /* | 1545 | /* |
@@ -1573,13 +1557,12 @@ static int irda_sendmsg_dgram(struct kiocb *iocb, struct socket *sock, | |||
1573 | struct sk_buff *skb; | 1557 | struct sk_buff *skb; |
1574 | int err; | 1558 | int err; |
1575 | 1559 | ||
1576 | lock_kernel(); | ||
1577 | |||
1578 | IRDA_DEBUG(4, "%s(), len=%zd\n", __func__, len); | 1560 | IRDA_DEBUG(4, "%s(), len=%zd\n", __func__, len); |
1579 | 1561 | ||
1580 | err = -EINVAL; | ||
1581 | if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_CMSG_COMPAT)) | 1562 | if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_CMSG_COMPAT)) |
1582 | goto out; | 1563 | return -EINVAL; |
1564 | |||
1565 | lock_sock(sk); | ||
1583 | 1566 | ||
1584 | if (sk->sk_shutdown & SEND_SHUTDOWN) { | 1567 | if (sk->sk_shutdown & SEND_SHUTDOWN) { |
1585 | send_sig(SIGPIPE, current, 0); | 1568 | send_sig(SIGPIPE, current, 0); |
@@ -1630,10 +1613,12 @@ static int irda_sendmsg_dgram(struct kiocb *iocb, struct socket *sock, | |||
1630 | IRDA_DEBUG(0, "%s(), err=%d\n", __func__, err); | 1613 | IRDA_DEBUG(0, "%s(), err=%d\n", __func__, err); |
1631 | goto out; | 1614 | goto out; |
1632 | } | 1615 | } |
1633 | unlock_kernel(); | 1616 | |
1617 | release_sock(sk); | ||
1634 | return len; | 1618 | return len; |
1619 | |||
1635 | out: | 1620 | out: |
1636 | unlock_kernel(); | 1621 | release_sock(sk); |
1637 | return err; | 1622 | return err; |
1638 | } | 1623 | } |
1639 | 1624 | ||
@@ -1656,10 +1641,11 @@ static int irda_sendmsg_ultra(struct kiocb *iocb, struct socket *sock, | |||
1656 | 1641 | ||
1657 | IRDA_DEBUG(4, "%s(), len=%zd\n", __func__, len); | 1642 | IRDA_DEBUG(4, "%s(), len=%zd\n", __func__, len); |
1658 | 1643 | ||
1659 | lock_kernel(); | ||
1660 | err = -EINVAL; | 1644 | err = -EINVAL; |
1661 | if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_CMSG_COMPAT)) | 1645 | if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_CMSG_COMPAT)) |
1662 | goto out; | 1646 | return -EINVAL; |
1647 | |||
1648 | lock_sock(sk); | ||
1663 | 1649 | ||
1664 | err = -EPIPE; | 1650 | err = -EPIPE; |
1665 | if (sk->sk_shutdown & SEND_SHUTDOWN) { | 1651 | if (sk->sk_shutdown & SEND_SHUTDOWN) { |
@@ -1732,7 +1718,7 @@ static int irda_sendmsg_ultra(struct kiocb *iocb, struct socket *sock, | |||
1732 | if (err) | 1718 | if (err) |
1733 | IRDA_DEBUG(0, "%s(), err=%d\n", __func__, err); | 1719 | IRDA_DEBUG(0, "%s(), err=%d\n", __func__, err); |
1734 | out: | 1720 | out: |
1735 | unlock_kernel(); | 1721 | release_sock(sk); |
1736 | return err ? : len; | 1722 | return err ? : len; |
1737 | } | 1723 | } |
1738 | #endif /* CONFIG_IRDA_ULTRA */ | 1724 | #endif /* CONFIG_IRDA_ULTRA */ |
@@ -1747,7 +1733,7 @@ static int irda_shutdown(struct socket *sock, int how) | |||
1747 | 1733 | ||
1748 | IRDA_DEBUG(1, "%s(%p)\n", __func__, self); | 1734 | IRDA_DEBUG(1, "%s(%p)\n", __func__, self); |
1749 | 1735 | ||
1750 | lock_kernel(); | 1736 | lock_sock(sk); |
1751 | 1737 | ||
1752 | sk->sk_state = TCP_CLOSE; | 1738 | sk->sk_state = TCP_CLOSE; |
1753 | sk->sk_shutdown |= SEND_SHUTDOWN; | 1739 | sk->sk_shutdown |= SEND_SHUTDOWN; |
@@ -1769,7 +1755,7 @@ static int irda_shutdown(struct socket *sock, int how) | |||
1769 | self->daddr = DEV_ADDR_ANY; /* Until we get re-connected */ | 1755 | self->daddr = DEV_ADDR_ANY; /* Until we get re-connected */ |
1770 | self->saddr = 0x0; /* so IrLMP assign us any link */ | 1756 | self->saddr = 0x0; /* so IrLMP assign us any link */ |
1771 | 1757 | ||
1772 | unlock_kernel(); | 1758 | release_sock(sk); |
1773 | 1759 | ||
1774 | return 0; | 1760 | return 0; |
1775 | } | 1761 | } |
@@ -1786,7 +1772,6 @@ static unsigned int irda_poll(struct file * file, struct socket *sock, | |||
1786 | 1772 | ||
1787 | IRDA_DEBUG(4, "%s()\n", __func__); | 1773 | IRDA_DEBUG(4, "%s()\n", __func__); |
1788 | 1774 | ||
1789 | lock_kernel(); | ||
1790 | poll_wait(file, sk_sleep(sk), wait); | 1775 | poll_wait(file, sk_sleep(sk), wait); |
1791 | mask = 0; | 1776 | mask = 0; |
1792 | 1777 | ||
@@ -1834,20 +1819,8 @@ static unsigned int irda_poll(struct file * file, struct socket *sock, | |||
1834 | default: | 1819 | default: |
1835 | break; | 1820 | break; |
1836 | } | 1821 | } |
1837 | unlock_kernel(); | ||
1838 | return mask; | ||
1839 | } | ||
1840 | |||
1841 | static unsigned int irda_datagram_poll(struct file *file, struct socket *sock, | ||
1842 | poll_table *wait) | ||
1843 | { | ||
1844 | int err; | ||
1845 | 1822 | ||
1846 | lock_kernel(); | 1823 | return mask; |
1847 | err = datagram_poll(file, sock, wait); | ||
1848 | unlock_kernel(); | ||
1849 | |||
1850 | return err; | ||
1851 | } | 1824 | } |
1852 | 1825 | ||
1853 | /* | 1826 | /* |
@@ -1860,7 +1833,6 @@ static int irda_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
1860 | 1833 | ||
1861 | IRDA_DEBUG(4, "%s(), cmd=%#x\n", __func__, cmd); | 1834 | IRDA_DEBUG(4, "%s(), cmd=%#x\n", __func__, cmd); |
1862 | 1835 | ||
1863 | lock_kernel(); | ||
1864 | err = -EINVAL; | 1836 | err = -EINVAL; |
1865 | switch (cmd) { | 1837 | switch (cmd) { |
1866 | case TIOCOUTQ: { | 1838 | case TIOCOUTQ: { |
@@ -1903,7 +1875,6 @@ static int irda_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
1903 | IRDA_DEBUG(1, "%s(), doing device ioctl!\n", __func__); | 1875 | IRDA_DEBUG(1, "%s(), doing device ioctl!\n", __func__); |
1904 | err = -ENOIOCTLCMD; | 1876 | err = -ENOIOCTLCMD; |
1905 | } | 1877 | } |
1906 | unlock_kernel(); | ||
1907 | 1878 | ||
1908 | return err; | 1879 | return err; |
1909 | } | 1880 | } |
@@ -1927,7 +1898,7 @@ static int irda_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned lon | |||
1927 | * Set some options for the socket | 1898 | * Set some options for the socket |
1928 | * | 1899 | * |
1929 | */ | 1900 | */ |
1930 | static int __irda_setsockopt(struct socket *sock, int level, int optname, | 1901 | static int irda_setsockopt(struct socket *sock, int level, int optname, |
1931 | char __user *optval, unsigned int optlen) | 1902 | char __user *optval, unsigned int optlen) |
1932 | { | 1903 | { |
1933 | struct sock *sk = sock->sk; | 1904 | struct sock *sk = sock->sk; |
@@ -1935,13 +1906,15 @@ static int __irda_setsockopt(struct socket *sock, int level, int optname, | |||
1935 | struct irda_ias_set *ias_opt; | 1906 | struct irda_ias_set *ias_opt; |
1936 | struct ias_object *ias_obj; | 1907 | struct ias_object *ias_obj; |
1937 | struct ias_attrib * ias_attr; /* Attribute in IAS object */ | 1908 | struct ias_attrib * ias_attr; /* Attribute in IAS object */ |
1938 | int opt, free_ias = 0; | 1909 | int opt, free_ias = 0, err = 0; |
1939 | 1910 | ||
1940 | IRDA_DEBUG(2, "%s(%p)\n", __func__, self); | 1911 | IRDA_DEBUG(2, "%s(%p)\n", __func__, self); |
1941 | 1912 | ||
1942 | if (level != SOL_IRLMP) | 1913 | if (level != SOL_IRLMP) |
1943 | return -ENOPROTOOPT; | 1914 | return -ENOPROTOOPT; |
1944 | 1915 | ||
1916 | lock_sock(sk); | ||
1917 | |||
1945 | switch (optname) { | 1918 | switch (optname) { |
1946 | case IRLMP_IAS_SET: | 1919 | case IRLMP_IAS_SET: |
1947 | /* The user want to add an attribute to an existing IAS object | 1920 | /* The user want to add an attribute to an existing IAS object |
@@ -1951,17 +1924,22 @@ static int __irda_setsockopt(struct socket *sock, int level, int optname, | |||
1951 | * create the right attribute... | 1924 | * create the right attribute... |
1952 | */ | 1925 | */ |
1953 | 1926 | ||
1954 | if (optlen != sizeof(struct irda_ias_set)) | 1927 | if (optlen != sizeof(struct irda_ias_set)) { |
1955 | return -EINVAL; | 1928 | err = -EINVAL; |
1929 | goto out; | ||
1930 | } | ||
1956 | 1931 | ||
1957 | ias_opt = kmalloc(sizeof(struct irda_ias_set), GFP_ATOMIC); | 1932 | ias_opt = kmalloc(sizeof(struct irda_ias_set), GFP_ATOMIC); |
1958 | if (ias_opt == NULL) | 1933 | if (ias_opt == NULL) { |
1959 | return -ENOMEM; | 1934 | err = -ENOMEM; |
1935 | goto out; | ||
1936 | } | ||
1960 | 1937 | ||
1961 | /* Copy query to the driver. */ | 1938 | /* Copy query to the driver. */ |
1962 | if (copy_from_user(ias_opt, optval, optlen)) { | 1939 | if (copy_from_user(ias_opt, optval, optlen)) { |
1963 | kfree(ias_opt); | 1940 | kfree(ias_opt); |
1964 | return -EFAULT; | 1941 | err = -EFAULT; |
1942 | goto out; | ||
1965 | } | 1943 | } |
1966 | 1944 | ||
1967 | /* Find the object we target. | 1945 | /* Find the object we target. |
@@ -1971,7 +1949,8 @@ static int __irda_setsockopt(struct socket *sock, int level, int optname, | |||
1971 | if(ias_opt->irda_class_name[0] == '\0') { | 1949 | if(ias_opt->irda_class_name[0] == '\0') { |
1972 | if(self->ias_obj == NULL) { | 1950 | if(self->ias_obj == NULL) { |
1973 | kfree(ias_opt); | 1951 | kfree(ias_opt); |
1974 | return -EINVAL; | 1952 | err = -EINVAL; |
1953 | goto out; | ||
1975 | } | 1954 | } |
1976 | ias_obj = self->ias_obj; | 1955 | ias_obj = self->ias_obj; |
1977 | } else | 1956 | } else |
@@ -1983,7 +1962,8 @@ static int __irda_setsockopt(struct socket *sock, int level, int optname, | |||
1983 | if((!capable(CAP_NET_ADMIN)) && | 1962 | if((!capable(CAP_NET_ADMIN)) && |
1984 | ((ias_obj == NULL) || (ias_obj != self->ias_obj))) { | 1963 | ((ias_obj == NULL) || (ias_obj != self->ias_obj))) { |
1985 | kfree(ias_opt); | 1964 | kfree(ias_opt); |
1986 | return -EPERM; | 1965 | err = -EPERM; |
1966 | goto out; | ||
1987 | } | 1967 | } |
1988 | 1968 | ||
1989 | /* If the object doesn't exist, create it */ | 1969 | /* If the object doesn't exist, create it */ |
@@ -1993,7 +1973,8 @@ static int __irda_setsockopt(struct socket *sock, int level, int optname, | |||
1993 | jiffies); | 1973 | jiffies); |
1994 | if (ias_obj == NULL) { | 1974 | if (ias_obj == NULL) { |
1995 | kfree(ias_opt); | 1975 | kfree(ias_opt); |
1996 | return -ENOMEM; | 1976 | err = -ENOMEM; |
1977 | goto out; | ||
1997 | } | 1978 | } |
1998 | free_ias = 1; | 1979 | free_ias = 1; |
1999 | } | 1980 | } |
@@ -2005,7 +1986,8 @@ static int __irda_setsockopt(struct socket *sock, int level, int optname, | |||
2005 | kfree(ias_obj->name); | 1986 | kfree(ias_obj->name); |
2006 | kfree(ias_obj); | 1987 | kfree(ias_obj); |
2007 | } | 1988 | } |
2008 | return -EINVAL; | 1989 | err = -EINVAL; |
1990 | goto out; | ||
2009 | } | 1991 | } |
2010 | 1992 | ||
2011 | /* Look at the type */ | 1993 | /* Look at the type */ |
@@ -2028,7 +2010,8 @@ static int __irda_setsockopt(struct socket *sock, int level, int optname, | |||
2028 | kfree(ias_obj); | 2010 | kfree(ias_obj); |
2029 | } | 2011 | } |
2030 | 2012 | ||
2031 | return -EINVAL; | 2013 | err = -EINVAL; |
2014 | goto out; | ||
2032 | } | 2015 | } |
2033 | /* Add an octet sequence attribute */ | 2016 | /* Add an octet sequence attribute */ |
2034 | irias_add_octseq_attrib( | 2017 | irias_add_octseq_attrib( |
@@ -2060,7 +2043,8 @@ static int __irda_setsockopt(struct socket *sock, int level, int optname, | |||
2060 | kfree(ias_obj->name); | 2043 | kfree(ias_obj->name); |
2061 | kfree(ias_obj); | 2044 | kfree(ias_obj); |
2062 | } | 2045 | } |
2063 | return -EINVAL; | 2046 | err = -EINVAL; |
2047 | goto out; | ||
2064 | } | 2048 | } |
2065 | irias_insert_object(ias_obj); | 2049 | irias_insert_object(ias_obj); |
2066 | kfree(ias_opt); | 2050 | kfree(ias_opt); |
@@ -2071,17 +2055,22 @@ static int __irda_setsockopt(struct socket *sock, int level, int optname, | |||
2071 | * object is not owned by the kernel and delete it. | 2055 | * object is not owned by the kernel and delete it. |
2072 | */ | 2056 | */ |
2073 | 2057 | ||
2074 | if (optlen != sizeof(struct irda_ias_set)) | 2058 | if (optlen != sizeof(struct irda_ias_set)) { |
2075 | return -EINVAL; | 2059 | err = -EINVAL; |
2060 | goto out; | ||
2061 | } | ||
2076 | 2062 | ||
2077 | ias_opt = kmalloc(sizeof(struct irda_ias_set), GFP_ATOMIC); | 2063 | ias_opt = kmalloc(sizeof(struct irda_ias_set), GFP_ATOMIC); |
2078 | if (ias_opt == NULL) | 2064 | if (ias_opt == NULL) { |
2079 | return -ENOMEM; | 2065 | err = -ENOMEM; |
2066 | goto out; | ||
2067 | } | ||
2080 | 2068 | ||
2081 | /* Copy query to the driver. */ | 2069 | /* Copy query to the driver. */ |
2082 | if (copy_from_user(ias_opt, optval, optlen)) { | 2070 | if (copy_from_user(ias_opt, optval, optlen)) { |
2083 | kfree(ias_opt); | 2071 | kfree(ias_opt); |
2084 | return -EFAULT; | 2072 | err = -EFAULT; |
2073 | goto out; | ||
2085 | } | 2074 | } |
2086 | 2075 | ||
2087 | /* Find the object we target. | 2076 | /* Find the object we target. |
@@ -2094,7 +2083,8 @@ static int __irda_setsockopt(struct socket *sock, int level, int optname, | |||
2094 | ias_obj = irias_find_object(ias_opt->irda_class_name); | 2083 | ias_obj = irias_find_object(ias_opt->irda_class_name); |
2095 | if(ias_obj == (struct ias_object *) NULL) { | 2084 | if(ias_obj == (struct ias_object *) NULL) { |
2096 | kfree(ias_opt); | 2085 | kfree(ias_opt); |
2097 | return -EINVAL; | 2086 | err = -EINVAL; |
2087 | goto out; | ||
2098 | } | 2088 | } |
2099 | 2089 | ||
2100 | /* Only ROOT can mess with the global IAS database. | 2090 | /* Only ROOT can mess with the global IAS database. |
@@ -2103,7 +2093,8 @@ static int __irda_setsockopt(struct socket *sock, int level, int optname, | |||
2103 | if((!capable(CAP_NET_ADMIN)) && | 2093 | if((!capable(CAP_NET_ADMIN)) && |
2104 | ((ias_obj == NULL) || (ias_obj != self->ias_obj))) { | 2094 | ((ias_obj == NULL) || (ias_obj != self->ias_obj))) { |
2105 | kfree(ias_opt); | 2095 | kfree(ias_opt); |
2106 | return -EPERM; | 2096 | err = -EPERM; |
2097 | goto out; | ||
2107 | } | 2098 | } |
2108 | 2099 | ||
2109 | /* Find the attribute (in the object) we target */ | 2100 | /* Find the attribute (in the object) we target */ |
@@ -2111,14 +2102,16 @@ static int __irda_setsockopt(struct socket *sock, int level, int optname, | |||
2111 | ias_opt->irda_attrib_name); | 2102 | ias_opt->irda_attrib_name); |
2112 | if(ias_attr == (struct ias_attrib *) NULL) { | 2103 | if(ias_attr == (struct ias_attrib *) NULL) { |
2113 | kfree(ias_opt); | 2104 | kfree(ias_opt); |
2114 | return -EINVAL; | 2105 | err = -EINVAL; |
2106 | goto out; | ||
2115 | } | 2107 | } |
2116 | 2108 | ||
2117 | /* Check is the user space own the object */ | 2109 | /* Check is the user space own the object */ |
2118 | if(ias_attr->value->owner != IAS_USER_ATTR) { | 2110 | if(ias_attr->value->owner != IAS_USER_ATTR) { |
2119 | IRDA_DEBUG(1, "%s(), attempting to delete a kernel attribute\n", __func__); | 2111 | IRDA_DEBUG(1, "%s(), attempting to delete a kernel attribute\n", __func__); |
2120 | kfree(ias_opt); | 2112 | kfree(ias_opt); |
2121 | return -EPERM; | 2113 | err = -EPERM; |
2114 | goto out; | ||
2122 | } | 2115 | } |
2123 | 2116 | ||
2124 | /* Remove the attribute (and maybe the object) */ | 2117 | /* Remove the attribute (and maybe the object) */ |
@@ -2126,11 +2119,15 @@ static int __irda_setsockopt(struct socket *sock, int level, int optname, | |||
2126 | kfree(ias_opt); | 2119 | kfree(ias_opt); |
2127 | break; | 2120 | break; |
2128 | case IRLMP_MAX_SDU_SIZE: | 2121 | case IRLMP_MAX_SDU_SIZE: |
2129 | if (optlen < sizeof(int)) | 2122 | if (optlen < sizeof(int)) { |
2130 | return -EINVAL; | 2123 | err = -EINVAL; |
2124 | goto out; | ||
2125 | } | ||
2131 | 2126 | ||
2132 | if (get_user(opt, (int __user *)optval)) | 2127 | if (get_user(opt, (int __user *)optval)) { |
2133 | return -EFAULT; | 2128 | err = -EFAULT; |
2129 | goto out; | ||
2130 | } | ||
2134 | 2131 | ||
2135 | /* Only possible for a seqpacket service (TTP with SAR) */ | 2132 | /* Only possible for a seqpacket service (TTP with SAR) */ |
2136 | if (sk->sk_type != SOCK_SEQPACKET) { | 2133 | if (sk->sk_type != SOCK_SEQPACKET) { |
@@ -2140,16 +2137,21 @@ static int __irda_setsockopt(struct socket *sock, int level, int optname, | |||
2140 | } else { | 2137 | } else { |
2141 | IRDA_WARNING("%s: not allowed to set MAXSDUSIZE for this socket type!\n", | 2138 | IRDA_WARNING("%s: not allowed to set MAXSDUSIZE for this socket type!\n", |
2142 | __func__); | 2139 | __func__); |
2143 | return -ENOPROTOOPT; | 2140 | err = -ENOPROTOOPT; |
2141 | goto out; | ||
2144 | } | 2142 | } |
2145 | break; | 2143 | break; |
2146 | case IRLMP_HINTS_SET: | 2144 | case IRLMP_HINTS_SET: |
2147 | if (optlen < sizeof(int)) | 2145 | if (optlen < sizeof(int)) { |
2148 | return -EINVAL; | 2146 | err = -EINVAL; |
2147 | goto out; | ||
2148 | } | ||
2149 | 2149 | ||
2150 | /* The input is really a (__u8 hints[2]), easier as an int */ | 2150 | /* The input is really a (__u8 hints[2]), easier as an int */ |
2151 | if (get_user(opt, (int __user *)optval)) | 2151 | if (get_user(opt, (int __user *)optval)) { |
2152 | return -EFAULT; | 2152 | err = -EFAULT; |
2153 | goto out; | ||
2154 | } | ||
2153 | 2155 | ||
2154 | /* Unregister any old registration */ | 2156 | /* Unregister any old registration */ |
2155 | if (self->skey) | 2157 | if (self->skey) |
@@ -2163,12 +2165,16 @@ static int __irda_setsockopt(struct socket *sock, int level, int optname, | |||
2163 | * making a discovery (nodes which don't match any hint | 2165 | * making a discovery (nodes which don't match any hint |
2164 | * bit in the mask are not reported). | 2166 | * bit in the mask are not reported). |
2165 | */ | 2167 | */ |
2166 | if (optlen < sizeof(int)) | 2168 | if (optlen < sizeof(int)) { |
2167 | return -EINVAL; | 2169 | err = -EINVAL; |
2170 | goto out; | ||
2171 | } | ||
2168 | 2172 | ||
2169 | /* The input is really a (__u8 hints[2]), easier as an int */ | 2173 | /* The input is really a (__u8 hints[2]), easier as an int */ |
2170 | if (get_user(opt, (int __user *)optval)) | 2174 | if (get_user(opt, (int __user *)optval)) { |
2171 | return -EFAULT; | 2175 | err = -EFAULT; |
2176 | goto out; | ||
2177 | } | ||
2172 | 2178 | ||
2173 | /* Set the new hint mask */ | 2179 | /* Set the new hint mask */ |
2174 | self->mask.word = (__u16) opt; | 2180 | self->mask.word = (__u16) opt; |
@@ -2180,19 +2186,12 @@ static int __irda_setsockopt(struct socket *sock, int level, int optname, | |||
2180 | 2186 | ||
2181 | break; | 2187 | break; |
2182 | default: | 2188 | default: |
2183 | return -ENOPROTOOPT; | 2189 | err = -ENOPROTOOPT; |
2190 | break; | ||
2184 | } | 2191 | } |
2185 | return 0; | ||
2186 | } | ||
2187 | 2192 | ||
2188 | static int irda_setsockopt(struct socket *sock, int level, int optname, | 2193 | out: |
2189 | char __user *optval, unsigned int optlen) | 2194 | release_sock(sk); |
2190 | { | ||
2191 | int err; | ||
2192 | |||
2193 | lock_kernel(); | ||
2194 | err = __irda_setsockopt(sock, level, optname, optval, optlen); | ||
2195 | unlock_kernel(); | ||
2196 | 2195 | ||
2197 | return err; | 2196 | return err; |
2198 | } | 2197 | } |
@@ -2249,7 +2248,7 @@ static int irda_extract_ias_value(struct irda_ias_set *ias_opt, | |||
2249 | /* | 2248 | /* |
2250 | * Function irda_getsockopt (sock, level, optname, optval, optlen) | 2249 | * Function irda_getsockopt (sock, level, optname, optval, optlen) |
2251 | */ | 2250 | */ |
2252 | static int __irda_getsockopt(struct socket *sock, int level, int optname, | 2251 | static int irda_getsockopt(struct socket *sock, int level, int optname, |
2253 | char __user *optval, int __user *optlen) | 2252 | char __user *optval, int __user *optlen) |
2254 | { | 2253 | { |
2255 | struct sock *sk = sock->sk; | 2254 | struct sock *sk = sock->sk; |
@@ -2262,7 +2261,7 @@ static int __irda_getsockopt(struct socket *sock, int level, int optname, | |||
2262 | int daddr = DEV_ADDR_ANY; /* Dest address for IAS queries */ | 2261 | int daddr = DEV_ADDR_ANY; /* Dest address for IAS queries */ |
2263 | int val = 0; | 2262 | int val = 0; |
2264 | int len = 0; | 2263 | int len = 0; |
2265 | int err; | 2264 | int err = 0; |
2266 | int offset, total; | 2265 | int offset, total; |
2267 | 2266 | ||
2268 | IRDA_DEBUG(2, "%s(%p)\n", __func__, self); | 2267 | IRDA_DEBUG(2, "%s(%p)\n", __func__, self); |
@@ -2276,29 +2275,35 @@ static int __irda_getsockopt(struct socket *sock, int level, int optname, | |||
2276 | if(len < 0) | 2275 | if(len < 0) |
2277 | return -EINVAL; | 2276 | return -EINVAL; |
2278 | 2277 | ||
2278 | lock_sock(sk); | ||
2279 | |||
2279 | switch (optname) { | 2280 | switch (optname) { |
2280 | case IRLMP_ENUMDEVICES: | 2281 | case IRLMP_ENUMDEVICES: |
2282 | |||
2283 | /* Offset to first device entry */ | ||
2284 | offset = sizeof(struct irda_device_list) - | ||
2285 | sizeof(struct irda_device_info); | ||
2286 | |||
2287 | if (len < offset) { | ||
2288 | err = -EINVAL; | ||
2289 | goto out; | ||
2290 | } | ||
2291 | |||
2281 | /* Ask lmp for the current discovery log */ | 2292 | /* Ask lmp for the current discovery log */ |
2282 | discoveries = irlmp_get_discoveries(&list.len, self->mask.word, | 2293 | discoveries = irlmp_get_discoveries(&list.len, self->mask.word, |
2283 | self->nslots); | 2294 | self->nslots); |
2284 | /* Check if the we got some results */ | 2295 | /* Check if the we got some results */ |
2285 | if (discoveries == NULL) | 2296 | if (discoveries == NULL) { |
2286 | return -EAGAIN; /* Didn't find any devices */ | 2297 | err = -EAGAIN; |
2287 | err = 0; | 2298 | goto out; /* Didn't find any devices */ |
2299 | } | ||
2288 | 2300 | ||
2289 | /* Write total list length back to client */ | 2301 | /* Write total list length back to client */ |
2290 | if (copy_to_user(optval, &list, | 2302 | if (copy_to_user(optval, &list, offset)) |
2291 | sizeof(struct irda_device_list) - | ||
2292 | sizeof(struct irda_device_info))) | ||
2293 | err = -EFAULT; | 2303 | err = -EFAULT; |
2294 | 2304 | ||
2295 | /* Offset to first device entry */ | ||
2296 | offset = sizeof(struct irda_device_list) - | ||
2297 | sizeof(struct irda_device_info); | ||
2298 | |||
2299 | /* Copy the list itself - watch for overflow */ | 2305 | /* Copy the list itself - watch for overflow */ |
2300 | if(list.len > 2048) | 2306 | if (list.len > 2048) { |
2301 | { | ||
2302 | err = -EINVAL; | 2307 | err = -EINVAL; |
2303 | goto bed; | 2308 | goto bed; |
2304 | } | 2309 | } |
@@ -2314,17 +2319,20 @@ static int __irda_getsockopt(struct socket *sock, int level, int optname, | |||
2314 | bed: | 2319 | bed: |
2315 | /* Free up our buffer */ | 2320 | /* Free up our buffer */ |
2316 | kfree(discoveries); | 2321 | kfree(discoveries); |
2317 | if (err) | ||
2318 | return err; | ||
2319 | break; | 2322 | break; |
2320 | case IRLMP_MAX_SDU_SIZE: | 2323 | case IRLMP_MAX_SDU_SIZE: |
2321 | val = self->max_data_size; | 2324 | val = self->max_data_size; |
2322 | len = sizeof(int); | 2325 | len = sizeof(int); |
2323 | if (put_user(len, optlen)) | 2326 | if (put_user(len, optlen)) { |
2324 | return -EFAULT; | 2327 | err = -EFAULT; |
2328 | goto out; | ||
2329 | } | ||
2330 | |||
2331 | if (copy_to_user(optval, &val, len)) { | ||
2332 | err = -EFAULT; | ||
2333 | goto out; | ||
2334 | } | ||
2325 | 2335 | ||
2326 | if (copy_to_user(optval, &val, len)) | ||
2327 | return -EFAULT; | ||
2328 | break; | 2336 | break; |
2329 | case IRLMP_IAS_GET: | 2337 | case IRLMP_IAS_GET: |
2330 | /* The user want an object from our local IAS database. | 2338 | /* The user want an object from our local IAS database. |
@@ -2332,17 +2340,22 @@ bed: | |||
2332 | * that we found */ | 2340 | * that we found */ |
2333 | 2341 | ||
2334 | /* Check that the user has allocated the right space for us */ | 2342 | /* Check that the user has allocated the right space for us */ |
2335 | if (len != sizeof(struct irda_ias_set)) | 2343 | if (len != sizeof(struct irda_ias_set)) { |
2336 | return -EINVAL; | 2344 | err = -EINVAL; |
2345 | goto out; | ||
2346 | } | ||
2337 | 2347 | ||
2338 | ias_opt = kmalloc(sizeof(struct irda_ias_set), GFP_ATOMIC); | 2348 | ias_opt = kmalloc(sizeof(struct irda_ias_set), GFP_ATOMIC); |
2339 | if (ias_opt == NULL) | 2349 | if (ias_opt == NULL) { |
2340 | return -ENOMEM; | 2350 | err = -ENOMEM; |
2351 | goto out; | ||
2352 | } | ||
2341 | 2353 | ||
2342 | /* Copy query to the driver. */ | 2354 | /* Copy query to the driver. */ |
2343 | if (copy_from_user(ias_opt, optval, len)) { | 2355 | if (copy_from_user(ias_opt, optval, len)) { |
2344 | kfree(ias_opt); | 2356 | kfree(ias_opt); |
2345 | return -EFAULT; | 2357 | err = -EFAULT; |
2358 | goto out; | ||
2346 | } | 2359 | } |
2347 | 2360 | ||
2348 | /* Find the object we target. | 2361 | /* Find the object we target. |
@@ -2355,7 +2368,8 @@ bed: | |||
2355 | ias_obj = irias_find_object(ias_opt->irda_class_name); | 2368 | ias_obj = irias_find_object(ias_opt->irda_class_name); |
2356 | if(ias_obj == (struct ias_object *) NULL) { | 2369 | if(ias_obj == (struct ias_object *) NULL) { |
2357 | kfree(ias_opt); | 2370 | kfree(ias_opt); |
2358 | return -EINVAL; | 2371 | err = -EINVAL; |
2372 | goto out; | ||
2359 | } | 2373 | } |
2360 | 2374 | ||
2361 | /* Find the attribute (in the object) we target */ | 2375 | /* Find the attribute (in the object) we target */ |
@@ -2363,21 +2377,23 @@ bed: | |||
2363 | ias_opt->irda_attrib_name); | 2377 | ias_opt->irda_attrib_name); |
2364 | if(ias_attr == (struct ias_attrib *) NULL) { | 2378 | if(ias_attr == (struct ias_attrib *) NULL) { |
2365 | kfree(ias_opt); | 2379 | kfree(ias_opt); |
2366 | return -EINVAL; | 2380 | err = -EINVAL; |
2381 | goto out; | ||
2367 | } | 2382 | } |
2368 | 2383 | ||
2369 | /* Translate from internal to user structure */ | 2384 | /* Translate from internal to user structure */ |
2370 | err = irda_extract_ias_value(ias_opt, ias_attr->value); | 2385 | err = irda_extract_ias_value(ias_opt, ias_attr->value); |
2371 | if(err) { | 2386 | if(err) { |
2372 | kfree(ias_opt); | 2387 | kfree(ias_opt); |
2373 | return err; | 2388 | goto out; |
2374 | } | 2389 | } |
2375 | 2390 | ||
2376 | /* Copy reply to the user */ | 2391 | /* Copy reply to the user */ |
2377 | if (copy_to_user(optval, ias_opt, | 2392 | if (copy_to_user(optval, ias_opt, |
2378 | sizeof(struct irda_ias_set))) { | 2393 | sizeof(struct irda_ias_set))) { |
2379 | kfree(ias_opt); | 2394 | kfree(ias_opt); |
2380 | return -EFAULT; | 2395 | err = -EFAULT; |
2396 | goto out; | ||
2381 | } | 2397 | } |
2382 | /* Note : don't need to put optlen, we checked it */ | 2398 | /* Note : don't need to put optlen, we checked it */ |
2383 | kfree(ias_opt); | 2399 | kfree(ias_opt); |
@@ -2388,17 +2404,22 @@ bed: | |||
2388 | * then wait for the answer to come back. */ | 2404 | * then wait for the answer to come back. */ |
2389 | 2405 | ||
2390 | /* Check that the user has allocated the right space for us */ | 2406 | /* Check that the user has allocated the right space for us */ |
2391 | if (len != sizeof(struct irda_ias_set)) | 2407 | if (len != sizeof(struct irda_ias_set)) { |
2392 | return -EINVAL; | 2408 | err = -EINVAL; |
2409 | goto out; | ||
2410 | } | ||
2393 | 2411 | ||
2394 | ias_opt = kmalloc(sizeof(struct irda_ias_set), GFP_ATOMIC); | 2412 | ias_opt = kmalloc(sizeof(struct irda_ias_set), GFP_ATOMIC); |
2395 | if (ias_opt == NULL) | 2413 | if (ias_opt == NULL) { |
2396 | return -ENOMEM; | 2414 | err = -ENOMEM; |
2415 | goto out; | ||
2416 | } | ||
2397 | 2417 | ||
2398 | /* Copy query to the driver. */ | 2418 | /* Copy query to the driver. */ |
2399 | if (copy_from_user(ias_opt, optval, len)) { | 2419 | if (copy_from_user(ias_opt, optval, len)) { |
2400 | kfree(ias_opt); | 2420 | kfree(ias_opt); |
2401 | return -EFAULT; | 2421 | err = -EFAULT; |
2422 | goto out; | ||
2402 | } | 2423 | } |
2403 | 2424 | ||
2404 | /* At this point, there are two cases... | 2425 | /* At this point, there are two cases... |
@@ -2419,7 +2440,8 @@ bed: | |||
2419 | daddr = ias_opt->daddr; | 2440 | daddr = ias_opt->daddr; |
2420 | if((!daddr) || (daddr == DEV_ADDR_ANY)) { | 2441 | if((!daddr) || (daddr == DEV_ADDR_ANY)) { |
2421 | kfree(ias_opt); | 2442 | kfree(ias_opt); |
2422 | return -EINVAL; | 2443 | err = -EINVAL; |
2444 | goto out; | ||
2423 | } | 2445 | } |
2424 | } | 2446 | } |
2425 | 2447 | ||
@@ -2428,7 +2450,8 @@ bed: | |||
2428 | IRDA_WARNING("%s: busy with a previous query\n", | 2450 | IRDA_WARNING("%s: busy with a previous query\n", |
2429 | __func__); | 2451 | __func__); |
2430 | kfree(ias_opt); | 2452 | kfree(ias_opt); |
2431 | return -EBUSY; | 2453 | err = -EBUSY; |
2454 | goto out; | ||
2432 | } | 2455 | } |
2433 | 2456 | ||
2434 | self->iriap = iriap_open(LSAP_ANY, IAS_CLIENT, self, | 2457 | self->iriap = iriap_open(LSAP_ANY, IAS_CLIENT, self, |
@@ -2436,7 +2459,8 @@ bed: | |||
2436 | 2459 | ||
2437 | if (self->iriap == NULL) { | 2460 | if (self->iriap == NULL) { |
2438 | kfree(ias_opt); | 2461 | kfree(ias_opt); |
2439 | return -ENOMEM; | 2462 | err = -ENOMEM; |
2463 | goto out; | ||
2440 | } | 2464 | } |
2441 | 2465 | ||
2442 | /* Treat unexpected wakeup as disconnect */ | 2466 | /* Treat unexpected wakeup as disconnect */ |
@@ -2455,7 +2479,8 @@ bed: | |||
2455 | * we can free it regardless! */ | 2479 | * we can free it regardless! */ |
2456 | kfree(ias_opt); | 2480 | kfree(ias_opt); |
2457 | /* Treat signals as disconnect */ | 2481 | /* Treat signals as disconnect */ |
2458 | return -EHOSTUNREACH; | 2482 | err = -EHOSTUNREACH; |
2483 | goto out; | ||
2459 | } | 2484 | } |
2460 | 2485 | ||
2461 | /* Check what happened */ | 2486 | /* Check what happened */ |
@@ -2465,9 +2490,11 @@ bed: | |||
2465 | /* Requested object/attribute doesn't exist */ | 2490 | /* Requested object/attribute doesn't exist */ |
2466 | if((self->errno == IAS_CLASS_UNKNOWN) || | 2491 | if((self->errno == IAS_CLASS_UNKNOWN) || |
2467 | (self->errno == IAS_ATTRIB_UNKNOWN)) | 2492 | (self->errno == IAS_ATTRIB_UNKNOWN)) |
2468 | return (-EADDRNOTAVAIL); | 2493 | err = -EADDRNOTAVAIL; |
2469 | else | 2494 | else |
2470 | return (-EHOSTUNREACH); | 2495 | err = -EHOSTUNREACH; |
2496 | |||
2497 | goto out; | ||
2471 | } | 2498 | } |
2472 | 2499 | ||
2473 | /* Translate from internal to user structure */ | 2500 | /* Translate from internal to user structure */ |
@@ -2476,14 +2503,15 @@ bed: | |||
2476 | irias_delete_value(self->ias_result); | 2503 | irias_delete_value(self->ias_result); |
2477 | if (err) { | 2504 | if (err) { |
2478 | kfree(ias_opt); | 2505 | kfree(ias_opt); |
2479 | return err; | 2506 | goto out; |
2480 | } | 2507 | } |
2481 | 2508 | ||
2482 | /* Copy reply to the user */ | 2509 | /* Copy reply to the user */ |
2483 | if (copy_to_user(optval, ias_opt, | 2510 | if (copy_to_user(optval, ias_opt, |
2484 | sizeof(struct irda_ias_set))) { | 2511 | sizeof(struct irda_ias_set))) { |
2485 | kfree(ias_opt); | 2512 | kfree(ias_opt); |
2486 | return -EFAULT; | 2513 | err = -EFAULT; |
2514 | goto out; | ||
2487 | } | 2515 | } |
2488 | /* Note : don't need to put optlen, we checked it */ | 2516 | /* Note : don't need to put optlen, we checked it */ |
2489 | kfree(ias_opt); | 2517 | kfree(ias_opt); |
@@ -2504,11 +2532,15 @@ bed: | |||
2504 | */ | 2532 | */ |
2505 | 2533 | ||
2506 | /* Check that the user is passing us an int */ | 2534 | /* Check that the user is passing us an int */ |
2507 | if (len != sizeof(int)) | 2535 | if (len != sizeof(int)) { |
2508 | return -EINVAL; | 2536 | err = -EINVAL; |
2537 | goto out; | ||
2538 | } | ||
2509 | /* Get timeout in ms (max time we block the caller) */ | 2539 | /* Get timeout in ms (max time we block the caller) */ |
2510 | if (get_user(val, (int __user *)optval)) | 2540 | if (get_user(val, (int __user *)optval)) { |
2511 | return -EFAULT; | 2541 | err = -EFAULT; |
2542 | goto out; | ||
2543 | } | ||
2512 | 2544 | ||
2513 | /* Tell IrLMP we want to be notified */ | 2545 | /* Tell IrLMP we want to be notified */ |
2514 | irlmp_update_client(self->ckey, self->mask.word, | 2546 | irlmp_update_client(self->ckey, self->mask.word, |
@@ -2520,8 +2552,6 @@ bed: | |||
2520 | 2552 | ||
2521 | /* Wait until a node is discovered */ | 2553 | /* Wait until a node is discovered */ |
2522 | if (!self->cachedaddr) { | 2554 | if (!self->cachedaddr) { |
2523 | int ret = 0; | ||
2524 | |||
2525 | IRDA_DEBUG(1, "%s(), nothing discovered yet, going to sleep...\n", __func__); | 2555 | IRDA_DEBUG(1, "%s(), nothing discovered yet, going to sleep...\n", __func__); |
2526 | 2556 | ||
2527 | /* Set watchdog timer to expire in <val> ms. */ | 2557 | /* Set watchdog timer to expire in <val> ms. */ |
@@ -2534,7 +2564,7 @@ bed: | |||
2534 | /* Wait for IR-LMP to call us back */ | 2564 | /* Wait for IR-LMP to call us back */ |
2535 | __wait_event_interruptible(self->query_wait, | 2565 | __wait_event_interruptible(self->query_wait, |
2536 | (self->cachedaddr != 0 || self->errno == -ETIME), | 2566 | (self->cachedaddr != 0 || self->errno == -ETIME), |
2537 | ret); | 2567 | err); |
2538 | 2568 | ||
2539 | /* If watchdog is still activated, kill it! */ | 2569 | /* If watchdog is still activated, kill it! */ |
2540 | if(timer_pending(&(self->watchdog))) | 2570 | if(timer_pending(&(self->watchdog))) |
@@ -2542,8 +2572,8 @@ bed: | |||
2542 | 2572 | ||
2543 | IRDA_DEBUG(1, "%s(), ...waking up !\n", __func__); | 2573 | IRDA_DEBUG(1, "%s(), ...waking up !\n", __func__); |
2544 | 2574 | ||
2545 | if (ret != 0) | 2575 | if (err != 0) |
2546 | return ret; | 2576 | goto out; |
2547 | } | 2577 | } |
2548 | else | 2578 | else |
2549 | IRDA_DEBUG(1, "%s(), found immediately !\n", | 2579 | IRDA_DEBUG(1, "%s(), found immediately !\n", |
@@ -2566,25 +2596,19 @@ bed: | |||
2566 | * If the user want more details, he should query | 2596 | * If the user want more details, he should query |
2567 | * the whole discovery log and pick one device... | 2597 | * the whole discovery log and pick one device... |
2568 | */ | 2598 | */ |
2569 | if (put_user(daddr, (int __user *)optval)) | 2599 | if (put_user(daddr, (int __user *)optval)) { |
2570 | return -EFAULT; | 2600 | err = -EFAULT; |
2601 | goto out; | ||
2602 | } | ||
2571 | 2603 | ||
2572 | break; | 2604 | break; |
2573 | default: | 2605 | default: |
2574 | return -ENOPROTOOPT; | 2606 | err = -ENOPROTOOPT; |
2575 | } | 2607 | } |
2576 | 2608 | ||
2577 | return 0; | 2609 | out: |
2578 | } | ||
2579 | |||
2580 | static int irda_getsockopt(struct socket *sock, int level, int optname, | ||
2581 | char __user *optval, int __user *optlen) | ||
2582 | { | ||
2583 | int err; | ||
2584 | 2610 | ||
2585 | lock_kernel(); | 2611 | release_sock(sk); |
2586 | err = __irda_getsockopt(sock, level, optname, optval, optlen); | ||
2587 | unlock_kernel(); | ||
2588 | 2612 | ||
2589 | return err; | 2613 | return err; |
2590 | } | 2614 | } |
@@ -2628,7 +2652,7 @@ static const struct proto_ops irda_seqpacket_ops = { | |||
2628 | .socketpair = sock_no_socketpair, | 2652 | .socketpair = sock_no_socketpair, |
2629 | .accept = irda_accept, | 2653 | .accept = irda_accept, |
2630 | .getname = irda_getname, | 2654 | .getname = irda_getname, |
2631 | .poll = irda_datagram_poll, | 2655 | .poll = datagram_poll, |
2632 | .ioctl = irda_ioctl, | 2656 | .ioctl = irda_ioctl, |
2633 | #ifdef CONFIG_COMPAT | 2657 | #ifdef CONFIG_COMPAT |
2634 | .compat_ioctl = irda_compat_ioctl, | 2658 | .compat_ioctl = irda_compat_ioctl, |
@@ -2652,7 +2676,7 @@ static const struct proto_ops irda_dgram_ops = { | |||
2652 | .socketpair = sock_no_socketpair, | 2676 | .socketpair = sock_no_socketpair, |
2653 | .accept = irda_accept, | 2677 | .accept = irda_accept, |
2654 | .getname = irda_getname, | 2678 | .getname = irda_getname, |
2655 | .poll = irda_datagram_poll, | 2679 | .poll = datagram_poll, |
2656 | .ioctl = irda_ioctl, | 2680 | .ioctl = irda_ioctl, |
2657 | #ifdef CONFIG_COMPAT | 2681 | #ifdef CONFIG_COMPAT |
2658 | .compat_ioctl = irda_compat_ioctl, | 2682 | .compat_ioctl = irda_compat_ioctl, |
@@ -2677,7 +2701,7 @@ static const struct proto_ops irda_ultra_ops = { | |||
2677 | .socketpair = sock_no_socketpair, | 2701 | .socketpair = sock_no_socketpair, |
2678 | .accept = sock_no_accept, | 2702 | .accept = sock_no_accept, |
2679 | .getname = irda_getname, | 2703 | .getname = irda_getname, |
2680 | .poll = irda_datagram_poll, | 2704 | .poll = datagram_poll, |
2681 | .ioctl = irda_ioctl, | 2705 | .ioctl = irda_ioctl, |
2682 | #ifdef CONFIG_COMPAT | 2706 | #ifdef CONFIG_COMPAT |
2683 | .compat_ioctl = irda_compat_ioctl, | 2707 | .compat_ioctl = irda_compat_ioctl, |
diff --git a/net/irda/discovery.c b/net/irda/discovery.c index c1c8ae939126..36c3f037f172 100644 --- a/net/irda/discovery.c +++ b/net/irda/discovery.c | |||
@@ -315,7 +315,7 @@ struct irda_device_info *irlmp_copy_discoveries(hashbin_t *log, int *pn, | |||
315 | 315 | ||
316 | /* Get the actual number of device in the buffer and return */ | 316 | /* Get the actual number of device in the buffer and return */ |
317 | *pn = i; | 317 | *pn = i; |
318 | return(buffer); | 318 | return buffer; |
319 | } | 319 | } |
320 | 320 | ||
321 | #ifdef CONFIG_PROC_FS | 321 | #ifdef CONFIG_PROC_FS |
diff --git a/net/irda/ircomm/Makefile b/net/irda/ircomm/Makefile index 48689458c086..ab23b5ba7e33 100644 --- a/net/irda/ircomm/Makefile +++ b/net/irda/ircomm/Makefile | |||
@@ -4,5 +4,5 @@ | |||
4 | 4 | ||
5 | obj-$(CONFIG_IRCOMM) += ircomm.o ircomm-tty.o | 5 | obj-$(CONFIG_IRCOMM) += ircomm.o ircomm-tty.o |
6 | 6 | ||
7 | ircomm-objs := ircomm_core.o ircomm_event.o ircomm_lmp.o ircomm_ttp.o | 7 | ircomm-y := ircomm_core.o ircomm_event.o ircomm_lmp.o ircomm_ttp.o |
8 | ircomm-tty-objs := ircomm_tty.o ircomm_tty_attach.o ircomm_tty_ioctl.o ircomm_param.o | 8 | ircomm-tty-y := ircomm_tty.o ircomm_tty_attach.o ircomm_tty_ioctl.o ircomm_param.o |
diff --git a/net/irda/ircomm/ircomm_core.c b/net/irda/ircomm/ircomm_core.c index e97082017f4f..52079f19bbbe 100644 --- a/net/irda/ircomm/ircomm_core.c +++ b/net/irda/ircomm/ircomm_core.c | |||
@@ -244,14 +244,8 @@ EXPORT_SYMBOL(ircomm_connect_request); | |||
244 | void ircomm_connect_indication(struct ircomm_cb *self, struct sk_buff *skb, | 244 | void ircomm_connect_indication(struct ircomm_cb *self, struct sk_buff *skb, |
245 | struct ircomm_info *info) | 245 | struct ircomm_info *info) |
246 | { | 246 | { |
247 | int clen = 0; | ||
248 | |||
249 | IRDA_DEBUG(2, "%s()\n", __func__ ); | 247 | IRDA_DEBUG(2, "%s()\n", __func__ ); |
250 | 248 | ||
251 | /* Check if the packet contains data on the control channel */ | ||
252 | if (skb->len > 0) | ||
253 | clen = skb->data[0]; | ||
254 | |||
255 | /* | 249 | /* |
256 | * If there are any data hiding in the control channel, we must | 250 | * If there are any data hiding in the control channel, we must |
257 | * deliver it first. The side effect is that the control channel | 251 | * deliver it first. The side effect is that the control channel |
diff --git a/net/irda/ircomm/ircomm_lmp.c b/net/irda/ircomm/ircomm_lmp.c index 08fb54dc8c41..3b8095c771d4 100644 --- a/net/irda/ircomm/ircomm_lmp.c +++ b/net/irda/ircomm/ircomm_lmp.c | |||
@@ -75,7 +75,6 @@ static int ircomm_lmp_connect_response(struct ircomm_cb *self, | |||
75 | struct sk_buff *userdata) | 75 | struct sk_buff *userdata) |
76 | { | 76 | { |
77 | struct sk_buff *tx_skb; | 77 | struct sk_buff *tx_skb; |
78 | int ret; | ||
79 | 78 | ||
80 | IRDA_DEBUG(0, "%s()\n", __func__ ); | 79 | IRDA_DEBUG(0, "%s()\n", __func__ ); |
81 | 80 | ||
@@ -100,9 +99,7 @@ static int ircomm_lmp_connect_response(struct ircomm_cb *self, | |||
100 | tx_skb = userdata; | 99 | tx_skb = userdata; |
101 | } | 100 | } |
102 | 101 | ||
103 | ret = irlmp_connect_response(self->lsap, tx_skb); | 102 | return irlmp_connect_response(self->lsap, tx_skb); |
104 | |||
105 | return 0; | ||
106 | } | 103 | } |
107 | 104 | ||
108 | static int ircomm_lmp_disconnect_request(struct ircomm_cb *self, | 105 | static int ircomm_lmp_disconnect_request(struct ircomm_cb *self, |
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c index faa82ca2dfdc..b3cc8b3989a9 100644 --- a/net/irda/ircomm/ircomm_tty.c +++ b/net/irda/ircomm/ircomm_tty.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/seq_file.h> | 38 | #include <linux/seq_file.h> |
39 | #include <linux/termios.h> | 39 | #include <linux/termios.h> |
40 | #include <linux/tty.h> | 40 | #include <linux/tty.h> |
41 | #include <linux/tty_flip.h> | ||
41 | #include <linux/interrupt.h> | 42 | #include <linux/interrupt.h> |
42 | #include <linux/device.h> /* for MODULE_ALIAS_CHARDEV_MAJOR */ | 43 | #include <linux/device.h> /* for MODULE_ALIAS_CHARDEV_MAJOR */ |
43 | 44 | ||
@@ -449,8 +450,8 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp) | |||
449 | } | 450 | } |
450 | 451 | ||
451 | #ifdef SERIAL_DO_RESTART | 452 | #ifdef SERIAL_DO_RESTART |
452 | return ((self->flags & ASYNC_HUP_NOTIFY) ? | 453 | return (self->flags & ASYNC_HUP_NOTIFY) ? |
453 | -EAGAIN : -ERESTARTSYS); | 454 | -EAGAIN : -ERESTARTSYS; |
454 | #else | 455 | #else |
455 | return -EAGAIN; | 456 | return -EAGAIN; |
456 | #endif | 457 | #endif |
@@ -1132,7 +1133,6 @@ static int ircomm_tty_data_indication(void *instance, void *sap, | |||
1132 | struct sk_buff *skb) | 1133 | struct sk_buff *skb) |
1133 | { | 1134 | { |
1134 | struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance; | 1135 | struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance; |
1135 | struct tty_ldisc *ld; | ||
1136 | 1136 | ||
1137 | IRDA_DEBUG(2, "%s()\n", __func__ ); | 1137 | IRDA_DEBUG(2, "%s()\n", __func__ ); |
1138 | 1138 | ||
@@ -1161,15 +1161,11 @@ static int ircomm_tty_data_indication(void *instance, void *sap, | |||
1161 | } | 1161 | } |
1162 | 1162 | ||
1163 | /* | 1163 | /* |
1164 | * Just give it over to the line discipline. There is no need to | 1164 | * Use flip buffer functions since the code may be called from interrupt |
1165 | * involve the flip buffers, since we are not running in an interrupt | 1165 | * context |
1166 | * handler | ||
1167 | */ | 1166 | */ |
1168 | 1167 | tty_insert_flip_string(self->tty, skb->data, skb->len); | |
1169 | ld = tty_ldisc_ref(self->tty); | 1168 | tty_flip_buffer_push(self->tty); |
1170 | if (ld) | ||
1171 | ld->ops->receive_buf(self->tty, skb->data, NULL, skb->len); | ||
1172 | tty_ldisc_deref(ld); | ||
1173 | 1169 | ||
1174 | /* No need to kfree_skb - see ircomm_ttp_data_indication() */ | 1170 | /* No need to kfree_skb - see ircomm_ttp_data_indication() */ |
1175 | 1171 | ||
diff --git a/net/irda/ircomm/ircomm_tty_ioctl.c b/net/irda/ircomm/ircomm_tty_ioctl.c index 24cb3aa2bbfb..77c5e6499f8f 100644 --- a/net/irda/ircomm/ircomm_tty_ioctl.c +++ b/net/irda/ircomm/ircomm_tty_ioctl.c | |||
@@ -189,12 +189,12 @@ void ircomm_tty_set_termios(struct tty_struct *tty, | |||
189 | } | 189 | } |
190 | 190 | ||
191 | /* | 191 | /* |
192 | * Function ircomm_tty_tiocmget (tty, file) | 192 | * Function ircomm_tty_tiocmget (tty) |
193 | * | 193 | * |
194 | * | 194 | * |
195 | * | 195 | * |
196 | */ | 196 | */ |
197 | int ircomm_tty_tiocmget(struct tty_struct *tty, struct file *file) | 197 | int ircomm_tty_tiocmget(struct tty_struct *tty) |
198 | { | 198 | { |
199 | struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; | 199 | struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; |
200 | unsigned int result; | 200 | unsigned int result; |
@@ -214,12 +214,12 @@ int ircomm_tty_tiocmget(struct tty_struct *tty, struct file *file) | |||
214 | } | 214 | } |
215 | 215 | ||
216 | /* | 216 | /* |
217 | * Function ircomm_tty_tiocmset (tty, file, set, clear) | 217 | * Function ircomm_tty_tiocmset (tty, set, clear) |
218 | * | 218 | * |
219 | * | 219 | * |
220 | * | 220 | * |
221 | */ | 221 | */ |
222 | int ircomm_tty_tiocmset(struct tty_struct *tty, struct file *file, | 222 | int ircomm_tty_tiocmset(struct tty_struct *tty, |
223 | unsigned int set, unsigned int clear) | 223 | unsigned int set, unsigned int clear) |
224 | { | 224 | { |
225 | struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; | 225 | struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; |
@@ -365,12 +365,12 @@ static int ircomm_tty_set_serial_info(struct ircomm_tty_cb *self, | |||
365 | } | 365 | } |
366 | 366 | ||
367 | /* | 367 | /* |
368 | * Function ircomm_tty_ioctl (tty, file, cmd, arg) | 368 | * Function ircomm_tty_ioctl (tty, cmd, arg) |
369 | * | 369 | * |
370 | * | 370 | * |
371 | * | 371 | * |
372 | */ | 372 | */ |
373 | int ircomm_tty_ioctl(struct tty_struct *tty, struct file *file, | 373 | int ircomm_tty_ioctl(struct tty_struct *tty, |
374 | unsigned int cmd, unsigned long arg) | 374 | unsigned int cmd, unsigned long arg) |
375 | { | 375 | { |
376 | struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; | 376 | struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; |
diff --git a/net/irda/iriap.c b/net/irda/iriap.c index fce364c6c71a..f876eed7d4aa 100644 --- a/net/irda/iriap.c +++ b/net/irda/iriap.c | |||
@@ -87,6 +87,8 @@ static inline void iriap_start_watchdog_timer(struct iriap_cb *self, | |||
87 | iriap_watchdog_timer_expired); | 87 | iriap_watchdog_timer_expired); |
88 | } | 88 | } |
89 | 89 | ||
90 | static struct lock_class_key irias_objects_key; | ||
91 | |||
90 | /* | 92 | /* |
91 | * Function iriap_init (void) | 93 | * Function iriap_init (void) |
92 | * | 94 | * |
@@ -114,6 +116,9 @@ int __init iriap_init(void) | |||
114 | return -ENOMEM; | 116 | return -ENOMEM; |
115 | } | 117 | } |
116 | 118 | ||
119 | lockdep_set_class_and_name(&irias_objects->hb_spinlock, &irias_objects_key, | ||
120 | "irias_objects"); | ||
121 | |||
117 | /* | 122 | /* |
118 | * Register some default services for IrLMP | 123 | * Register some default services for IrLMP |
119 | */ | 124 | */ |
@@ -502,7 +507,8 @@ static void iriap_getvaluebyclass_confirm(struct iriap_cb *self, | |||
502 | IRDA_DEBUG(4, "%s(), strlen=%d\n", __func__, value_len); | 507 | IRDA_DEBUG(4, "%s(), strlen=%d\n", __func__, value_len); |
503 | 508 | ||
504 | /* Make sure the string is null-terminated */ | 509 | /* Make sure the string is null-terminated */ |
505 | fp[n+value_len] = 0x00; | 510 | if (n + value_len < skb->len) |
511 | fp[n + value_len] = 0x00; | ||
506 | IRDA_DEBUG(4, "Got string %s\n", fp+n); | 512 | IRDA_DEBUG(4, "Got string %s\n", fp+n); |
507 | 513 | ||
508 | /* Will truncate to IAS_MAX_STRING bytes */ | 514 | /* Will truncate to IAS_MAX_STRING bytes */ |
@@ -655,10 +661,16 @@ static void iriap_getvaluebyclass_indication(struct iriap_cb *self, | |||
655 | n = 1; | 661 | n = 1; |
656 | 662 | ||
657 | name_len = fp[n++]; | 663 | name_len = fp[n++]; |
664 | |||
665 | IRDA_ASSERT(name_len < IAS_MAX_CLASSNAME + 1, return;); | ||
666 | |||
658 | memcpy(name, fp+n, name_len); n+=name_len; | 667 | memcpy(name, fp+n, name_len); n+=name_len; |
659 | name[name_len] = '\0'; | 668 | name[name_len] = '\0'; |
660 | 669 | ||
661 | attr_len = fp[n++]; | 670 | attr_len = fp[n++]; |
671 | |||
672 | IRDA_ASSERT(attr_len < IAS_MAX_ATTRIBNAME + 1, return;); | ||
673 | |||
662 | memcpy(attr, fp+n, attr_len); n+=attr_len; | 674 | memcpy(attr, fp+n, attr_len); n+=attr_len; |
663 | attr[attr_len] = '\0'; | 675 | attr[attr_len] = '\0'; |
664 | 676 | ||
diff --git a/net/irda/irlan/Makefile b/net/irda/irlan/Makefile index 77549bc8641b..94eefbc8e6b9 100644 --- a/net/irda/irlan/Makefile +++ b/net/irda/irlan/Makefile | |||
@@ -4,4 +4,4 @@ | |||
4 | 4 | ||
5 | obj-$(CONFIG_IRLAN) += irlan.o | 5 | obj-$(CONFIG_IRLAN) += irlan.o |
6 | 6 | ||
7 | irlan-objs := irlan_common.o irlan_eth.o irlan_event.o irlan_client.o irlan_provider.o irlan_filter.o irlan_provider_event.o irlan_client_event.o | 7 | irlan-y := irlan_common.o irlan_eth.o irlan_event.o irlan_client.o irlan_provider.o irlan_filter.o irlan_provider_event.o irlan_client_event.o |
diff --git a/net/irda/irlan/irlan_eth.c b/net/irda/irlan/irlan_eth.c index 5bb8353105cc..8ee1ff6c742f 100644 --- a/net/irda/irlan/irlan_eth.c +++ b/net/irda/irlan/irlan_eth.c | |||
@@ -45,13 +45,11 @@ static int irlan_eth_close(struct net_device *dev); | |||
45 | static netdev_tx_t irlan_eth_xmit(struct sk_buff *skb, | 45 | static netdev_tx_t irlan_eth_xmit(struct sk_buff *skb, |
46 | struct net_device *dev); | 46 | struct net_device *dev); |
47 | static void irlan_eth_set_multicast_list( struct net_device *dev); | 47 | static void irlan_eth_set_multicast_list( struct net_device *dev); |
48 | static struct net_device_stats *irlan_eth_get_stats(struct net_device *dev); | ||
49 | 48 | ||
50 | static const struct net_device_ops irlan_eth_netdev_ops = { | 49 | static const struct net_device_ops irlan_eth_netdev_ops = { |
51 | .ndo_open = irlan_eth_open, | 50 | .ndo_open = irlan_eth_open, |
52 | .ndo_stop = irlan_eth_close, | 51 | .ndo_stop = irlan_eth_close, |
53 | .ndo_start_xmit = irlan_eth_xmit, | 52 | .ndo_start_xmit = irlan_eth_xmit, |
54 | .ndo_get_stats = irlan_eth_get_stats, | ||
55 | .ndo_set_multicast_list = irlan_eth_set_multicast_list, | 53 | .ndo_set_multicast_list = irlan_eth_set_multicast_list, |
56 | .ndo_change_mtu = eth_change_mtu, | 54 | .ndo_change_mtu = eth_change_mtu, |
57 | .ndo_validate_addr = eth_validate_addr, | 55 | .ndo_validate_addr = eth_validate_addr, |
@@ -208,10 +206,10 @@ static netdev_tx_t irlan_eth_xmit(struct sk_buff *skb, | |||
208 | * tried :-) DB | 206 | * tried :-) DB |
209 | */ | 207 | */ |
210 | /* irttp_data_request already free the packet */ | 208 | /* irttp_data_request already free the packet */ |
211 | self->stats.tx_dropped++; | 209 | dev->stats.tx_dropped++; |
212 | } else { | 210 | } else { |
213 | self->stats.tx_packets++; | 211 | dev->stats.tx_packets++; |
214 | self->stats.tx_bytes += len; | 212 | dev->stats.tx_bytes += len; |
215 | } | 213 | } |
216 | 214 | ||
217 | return NETDEV_TX_OK; | 215 | return NETDEV_TX_OK; |
@@ -226,15 +224,16 @@ static netdev_tx_t irlan_eth_xmit(struct sk_buff *skb, | |||
226 | int irlan_eth_receive(void *instance, void *sap, struct sk_buff *skb) | 224 | int irlan_eth_receive(void *instance, void *sap, struct sk_buff *skb) |
227 | { | 225 | { |
228 | struct irlan_cb *self = instance; | 226 | struct irlan_cb *self = instance; |
227 | struct net_device *dev = self->dev; | ||
229 | 228 | ||
230 | if (skb == NULL) { | 229 | if (skb == NULL) { |
231 | ++self->stats.rx_dropped; | 230 | dev->stats.rx_dropped++; |
232 | return 0; | 231 | return 0; |
233 | } | 232 | } |
234 | if (skb->len < ETH_HLEN) { | 233 | if (skb->len < ETH_HLEN) { |
235 | IRDA_DEBUG(0, "%s() : IrLAN frame too short (%d)\n", | 234 | IRDA_DEBUG(0, "%s() : IrLAN frame too short (%d)\n", |
236 | __func__, skb->len); | 235 | __func__, skb->len); |
237 | ++self->stats.rx_dropped; | 236 | dev->stats.rx_dropped++; |
238 | dev_kfree_skb(skb); | 237 | dev_kfree_skb(skb); |
239 | return 0; | 238 | return 0; |
240 | } | 239 | } |
@@ -244,10 +243,10 @@ int irlan_eth_receive(void *instance, void *sap, struct sk_buff *skb) | |||
244 | * might have been previously set by the low level IrDA network | 243 | * might have been previously set by the low level IrDA network |
245 | * device driver | 244 | * device driver |
246 | */ | 245 | */ |
247 | skb->protocol = eth_type_trans(skb, self->dev); /* Remove eth header */ | 246 | skb->protocol = eth_type_trans(skb, dev); /* Remove eth header */ |
248 | 247 | ||
249 | self->stats.rx_packets++; | 248 | dev->stats.rx_packets++; |
250 | self->stats.rx_bytes += skb->len; | 249 | dev->stats.rx_bytes += skb->len; |
251 | 250 | ||
252 | netif_rx(skb); /* Eat it! */ | 251 | netif_rx(skb); /* Eat it! */ |
253 | 252 | ||
@@ -348,16 +347,3 @@ static void irlan_eth_set_multicast_list(struct net_device *dev) | |||
348 | else | 347 | else |
349 | irlan_set_broadcast_filter(self, FALSE); | 348 | irlan_set_broadcast_filter(self, FALSE); |
350 | } | 349 | } |
351 | |||
352 | /* | ||
353 | * Function irlan_get_stats (dev) | ||
354 | * | ||
355 | * Get the current statistics for this device | ||
356 | * | ||
357 | */ | ||
358 | static struct net_device_stats *irlan_eth_get_stats(struct net_device *dev) | ||
359 | { | ||
360 | struct irlan_cb *self = netdev_priv(dev); | ||
361 | |||
362 | return &self->stats; | ||
363 | } | ||
diff --git a/net/irda/irlan/irlan_event.c b/net/irda/irlan/irlan_event.c index cbcb4eb54037..43f16040a6fe 100644 --- a/net/irda/irlan/irlan_event.c +++ b/net/irda/irlan/irlan_event.c | |||
@@ -24,7 +24,7 @@ | |||
24 | 24 | ||
25 | #include <net/irda/irlan_event.h> | 25 | #include <net/irda/irlan_event.h> |
26 | 26 | ||
27 | char *irlan_state[] = { | 27 | const char * const irlan_state[] = { |
28 | "IRLAN_IDLE", | 28 | "IRLAN_IDLE", |
29 | "IRLAN_QUERY", | 29 | "IRLAN_QUERY", |
30 | "IRLAN_CONN", | 30 | "IRLAN_CONN", |
diff --git a/net/irda/irlan/irlan_filter.c b/net/irda/irlan/irlan_filter.c index 9ff7823abec7..7977be7caf0f 100644 --- a/net/irda/irlan/irlan_filter.c +++ b/net/irda/irlan/irlan_filter.c | |||
@@ -143,12 +143,8 @@ void irlan_filter_request(struct irlan_cb *self, struct sk_buff *skb) | |||
143 | */ | 143 | */ |
144 | void irlan_check_command_param(struct irlan_cb *self, char *param, char *value) | 144 | void irlan_check_command_param(struct irlan_cb *self, char *param, char *value) |
145 | { | 145 | { |
146 | __u8 *bytes; | ||
147 | |||
148 | IRDA_DEBUG(4, "%s()\n", __func__ ); | 146 | IRDA_DEBUG(4, "%s()\n", __func__ ); |
149 | 147 | ||
150 | bytes = value; | ||
151 | |||
152 | IRDA_ASSERT(self != NULL, return;); | 148 | IRDA_ASSERT(self != NULL, return;); |
153 | IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); | 149 | IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); |
154 | 150 | ||
diff --git a/net/irda/irlan/irlan_provider.c b/net/irda/irlan/irlan_provider.c index 5cf5e6c872bb..b8af74ab8b68 100644 --- a/net/irda/irlan/irlan_provider.c +++ b/net/irda/irlan/irlan_provider.c | |||
@@ -128,7 +128,6 @@ static void irlan_provider_connect_indication(void *instance, void *sap, | |||
128 | { | 128 | { |
129 | struct irlan_cb *self; | 129 | struct irlan_cb *self; |
130 | struct tsap_cb *tsap; | 130 | struct tsap_cb *tsap; |
131 | __u32 saddr, daddr; | ||
132 | 131 | ||
133 | IRDA_DEBUG(0, "%s()\n", __func__ ); | 132 | IRDA_DEBUG(0, "%s()\n", __func__ ); |
134 | 133 | ||
@@ -141,8 +140,6 @@ static void irlan_provider_connect_indication(void *instance, void *sap, | |||
141 | IRDA_ASSERT(tsap == self->provider.tsap_ctrl,return;); | 140 | IRDA_ASSERT(tsap == self->provider.tsap_ctrl,return;); |
142 | IRDA_ASSERT(self->provider.state == IRLAN_IDLE, return;); | 141 | IRDA_ASSERT(self->provider.state == IRLAN_IDLE, return;); |
143 | 142 | ||
144 | daddr = irttp_get_daddr(tsap); | ||
145 | saddr = irttp_get_saddr(tsap); | ||
146 | self->provider.max_sdu_size = max_sdu_size; | 143 | self->provider.max_sdu_size = max_sdu_size; |
147 | self->provider.max_header_size = max_header_size; | 144 | self->provider.max_header_size = max_header_size; |
148 | 145 | ||
diff --git a/net/irda/irlap.c b/net/irda/irlap.c index 783c5f367d29..005b424494a0 100644 --- a/net/irda/irlap.c +++ b/net/irda/irlap.c | |||
@@ -165,7 +165,7 @@ struct irlap_cb *irlap_open(struct net_device *dev, struct qos_info *qos, | |||
165 | 165 | ||
166 | irlap_apply_default_connection_parameters(self); | 166 | irlap_apply_default_connection_parameters(self); |
167 | 167 | ||
168 | self->N3 = 3; /* # connections attemts to try before giving up */ | 168 | self->N3 = 3; /* # connections attempts to try before giving up */ |
169 | 169 | ||
170 | self->state = LAP_NDM; | 170 | self->state = LAP_NDM; |
171 | 171 | ||
diff --git a/net/irda/irlap_event.c b/net/irda/irlap_event.c index d434c8880745..ccd214f9d196 100644 --- a/net/irda/irlap_event.c +++ b/net/irda/irlap_event.c | |||
@@ -708,7 +708,7 @@ static int irlap_state_reply(struct irlap_cb *self, IRLAP_EVENT event, | |||
708 | 708 | ||
709 | self->frame_sent = TRUE; | 709 | self->frame_sent = TRUE; |
710 | } | 710 | } |
711 | /* Readjust our timer to accomodate devices | 711 | /* Readjust our timer to accommodate devices |
712 | * doing faster or slower discovery than us... | 712 | * doing faster or slower discovery than us... |
713 | * Jean II */ | 713 | * Jean II */ |
714 | irlap_start_query_timer(self, info->S, info->s); | 714 | irlap_start_query_timer(self, info->S, info->s); |
@@ -931,7 +931,7 @@ static int irlap_state_setup(struct irlap_cb *self, IRLAP_EVENT event, | |||
931 | irlap_send_rr_frame(self, CMD_FRAME); | 931 | irlap_send_rr_frame(self, CMD_FRAME); |
932 | 932 | ||
933 | /* The timer is set to half the normal timer to quickly | 933 | /* The timer is set to half the normal timer to quickly |
934 | * detect a failure to negociate the new connection | 934 | * detect a failure to negotiate the new connection |
935 | * parameters. IrLAP 6.11.3.2, note 3. | 935 | * parameters. IrLAP 6.11.3.2, note 3. |
936 | * Note that currently we don't process this failure | 936 | * Note that currently we don't process this failure |
937 | * properly, as we should do a quick disconnect. | 937 | * properly, as we should do a quick disconnect. |
@@ -1052,7 +1052,7 @@ static int irlap_state_xmit_p(struct irlap_cb *self, IRLAP_EVENT event, | |||
1052 | return -EPROTO; | 1052 | return -EPROTO; |
1053 | } | 1053 | } |
1054 | 1054 | ||
1055 | /* Substract space used by this skb */ | 1055 | /* Subtract space used by this skb */ |
1056 | self->bytes_left -= skb->len; | 1056 | self->bytes_left -= skb->len; |
1057 | #else /* CONFIG_IRDA_DYNAMIC_WINDOW */ | 1057 | #else /* CONFIG_IRDA_DYNAMIC_WINDOW */ |
1058 | /* Window has been adjusted for the max packet | 1058 | /* Window has been adjusted for the max packet |
@@ -1808,7 +1808,7 @@ static int irlap_state_xmit_s(struct irlap_cb *self, IRLAP_EVENT event, | |||
1808 | 1808 | ||
1809 | return -EPROTO; /* Try again later */ | 1809 | return -EPROTO; /* Try again later */ |
1810 | } | 1810 | } |
1811 | /* Substract space used by this skb */ | 1811 | /* Subtract space used by this skb */ |
1812 | self->bytes_left -= skb->len; | 1812 | self->bytes_left -= skb->len; |
1813 | #else /* CONFIG_IRDA_DYNAMIC_WINDOW */ | 1813 | #else /* CONFIG_IRDA_DYNAMIC_WINDOW */ |
1814 | /* Window has been adjusted for the max packet | 1814 | /* Window has been adjusted for the max packet |
@@ -2227,8 +2227,6 @@ static int irlap_state_nrm_s(struct irlap_cb *self, IRLAP_EVENT event, | |||
2227 | static int irlap_state_sclose(struct irlap_cb *self, IRLAP_EVENT event, | 2227 | static int irlap_state_sclose(struct irlap_cb *self, IRLAP_EVENT event, |
2228 | struct sk_buff *skb, struct irlap_info *info) | 2228 | struct sk_buff *skb, struct irlap_info *info) |
2229 | { | 2229 | { |
2230 | int ret = 0; | ||
2231 | |||
2232 | IRDA_DEBUG(1, "%s()\n", __func__); | 2230 | IRDA_DEBUG(1, "%s()\n", __func__); |
2233 | 2231 | ||
2234 | IRDA_ASSERT(self != NULL, return -ENODEV;); | 2232 | IRDA_ASSERT(self != NULL, return -ENODEV;); |
@@ -2289,7 +2287,6 @@ static int irlap_state_sclose(struct irlap_cb *self, IRLAP_EVENT event, | |||
2289 | IRDA_DEBUG(1, "%s(), Unknown event %d, (%s)\n", __func__, | 2287 | IRDA_DEBUG(1, "%s(), Unknown event %d, (%s)\n", __func__, |
2290 | event, irlap_event[event]); | 2288 | event, irlap_event[event]); |
2291 | 2289 | ||
2292 | ret = -EINVAL; | ||
2293 | break; | 2290 | break; |
2294 | } | 2291 | } |
2295 | 2292 | ||
diff --git a/net/irda/irlap_frame.c b/net/irda/irlap_frame.c index 688222cbf55b..8c004161a843 100644 --- a/net/irda/irlap_frame.c +++ b/net/irda/irlap_frame.c | |||
@@ -848,7 +848,7 @@ void irlap_send_data_primary_poll(struct irlap_cb *self, struct sk_buff *skb) | |||
848 | * though IrLAP is currently sending the *last* frame of the | 848 | * though IrLAP is currently sending the *last* frame of the |
849 | * tx-window, the driver most likely has only just started | 849 | * tx-window, the driver most likely has only just started |
850 | * sending the *first* frame of the same tx-window. | 850 | * sending the *first* frame of the same tx-window. |
851 | * I.e. we are always at the very begining of or Tx window. | 851 | * I.e. we are always at the very beginning of or Tx window. |
852 | * Now, we are supposed to set the final timer from the end | 852 | * Now, we are supposed to set the final timer from the end |
853 | * of our tx-window to let the other peer reply. So, we need | 853 | * of our tx-window to let the other peer reply. So, we need |
854 | * to add extra time to compensate for the fact that we | 854 | * to add extra time to compensate for the fact that we |
diff --git a/net/irda/irlmp.c b/net/irda/irlmp.c index 0e7d8bde145d..6115a44c0a24 100644 --- a/net/irda/irlmp.c +++ b/net/irda/irlmp.c | |||
@@ -939,7 +939,7 @@ struct irda_device_info *irlmp_get_discoveries(int *pn, __u16 mask, int nslots) | |||
939 | } | 939 | } |
940 | 940 | ||
941 | /* Return current cached discovery log */ | 941 | /* Return current cached discovery log */ |
942 | return(irlmp_copy_discoveries(irlmp->cachelog, pn, mask, TRUE)); | 942 | return irlmp_copy_discoveries(irlmp->cachelog, pn, mask, TRUE); |
943 | } | 943 | } |
944 | EXPORT_SYMBOL(irlmp_get_discoveries); | 944 | EXPORT_SYMBOL(irlmp_get_discoveries); |
945 | 945 | ||
diff --git a/net/irda/irlmp_event.c b/net/irda/irlmp_event.c index c1fb5db81042..9505a7d06f1a 100644 --- a/net/irda/irlmp_event.c +++ b/net/irda/irlmp_event.c | |||
@@ -498,7 +498,7 @@ static int irlmp_state_disconnected(struct lsap_cb *self, IRLMP_EVENT event, | |||
498 | switch (event) { | 498 | switch (event) { |
499 | #ifdef CONFIG_IRDA_ULTRA | 499 | #ifdef CONFIG_IRDA_ULTRA |
500 | case LM_UDATA_INDICATION: | 500 | case LM_UDATA_INDICATION: |
501 | /* This is most bizzare. Those packets are aka unreliable | 501 | /* This is most bizarre. Those packets are aka unreliable |
502 | * connected, aka IrLPT or SOCK_DGRAM/IRDAPROTO_UNITDATA. | 502 | * connected, aka IrLPT or SOCK_DGRAM/IRDAPROTO_UNITDATA. |
503 | * Why do we pass them as Ultra ??? Jean II */ | 503 | * Why do we pass them as Ultra ??? Jean II */ |
504 | irlmp_connless_data_indication(self, skb); | 504 | irlmp_connless_data_indication(self, skb); |
diff --git a/net/irda/irlmp_frame.c b/net/irda/irlmp_frame.c index 3750884094da..062e63b1c5c4 100644 --- a/net/irda/irlmp_frame.c +++ b/net/irda/irlmp_frame.c | |||
@@ -448,7 +448,7 @@ static struct lsap_cb *irlmp_find_lsap(struct lap_cb *self, __u8 dlsap_sel, | |||
448 | (self->cache.slsap_sel == slsap_sel) && | 448 | (self->cache.slsap_sel == slsap_sel) && |
449 | (self->cache.dlsap_sel == dlsap_sel)) | 449 | (self->cache.dlsap_sel == dlsap_sel)) |
450 | { | 450 | { |
451 | return (self->cache.lsap); | 451 | return self->cache.lsap; |
452 | } | 452 | } |
453 | #endif | 453 | #endif |
454 | 454 | ||
diff --git a/net/irda/irnet/Makefile b/net/irda/irnet/Makefile index b3ee01e0def3..61c365c8a2a0 100644 --- a/net/irda/irnet/Makefile +++ b/net/irda/irnet/Makefile | |||
@@ -4,4 +4,4 @@ | |||
4 | 4 | ||
5 | obj-$(CONFIG_IRNET) += irnet.o | 5 | obj-$(CONFIG_IRNET) += irnet.o |
6 | 6 | ||
7 | irnet-objs := irnet_ppp.o irnet_irda.o | 7 | irnet-y := irnet_ppp.o irnet_irda.o |
diff --git a/net/irda/irnet/irnet.h b/net/irda/irnet/irnet.h index 4300df35d37d..979ecb2435a7 100644 --- a/net/irda/irnet/irnet.h +++ b/net/irda/irnet/irnet.h | |||
@@ -73,7 +73,7 @@ | |||
73 | * Infinite thanks to those brave souls for providing the infrastructure | 73 | * Infinite thanks to those brave souls for providing the infrastructure |
74 | * upon which IrNET is built. | 74 | * upon which IrNET is built. |
75 | * | 75 | * |
76 | * Thanks to all my collegues in HP for helping me. In particular, | 76 | * Thanks to all my colleagues in HP for helping me. In particular, |
77 | * thanks to Salil Pradhan and Bill Serra for W2k testing... | 77 | * thanks to Salil Pradhan and Bill Serra for W2k testing... |
78 | * Thanks to Luiz Magalhaes for irnetd and much testing... | 78 | * Thanks to Luiz Magalhaes for irnetd and much testing... |
79 | * | 79 | * |
@@ -458,6 +458,8 @@ typedef struct irnet_socket | |||
458 | int disco_index; /* Last read in the discovery log */ | 458 | int disco_index; /* Last read in the discovery log */ |
459 | int disco_number; /* Size of the discovery log */ | 459 | int disco_number; /* Size of the discovery log */ |
460 | 460 | ||
461 | struct mutex lock; | ||
462 | |||
461 | } irnet_socket; | 463 | } irnet_socket; |
462 | 464 | ||
463 | /* | 465 | /* |
diff --git a/net/irda/irnet/irnet_irda.c b/net/irda/irnet/irnet_irda.c index e98e40d76f4f..7f17a8020e8a 100644 --- a/net/irda/irnet/irnet_irda.c +++ b/net/irda/irnet/irnet_irda.c | |||
@@ -238,7 +238,7 @@ irnet_ias_to_tsap(irnet_socket * self, | |||
238 | DEXIT(IRDA_SR_TRACE, "\n"); | 238 | DEXIT(IRDA_SR_TRACE, "\n"); |
239 | 239 | ||
240 | /* Return the TSAP */ | 240 | /* Return the TSAP */ |
241 | return(dtsap_sel); | 241 | return dtsap_sel; |
242 | } | 242 | } |
243 | 243 | ||
244 | /*------------------------------------------------------------------*/ | 244 | /*------------------------------------------------------------------*/ |
@@ -301,7 +301,7 @@ irnet_connect_tsap(irnet_socket * self) | |||
301 | { | 301 | { |
302 | clear_bit(0, &self->ttp_connect); | 302 | clear_bit(0, &self->ttp_connect); |
303 | DERROR(IRDA_SR_ERROR, "connect aborted!\n"); | 303 | DERROR(IRDA_SR_ERROR, "connect aborted!\n"); |
304 | return(err); | 304 | return err; |
305 | } | 305 | } |
306 | 306 | ||
307 | /* Connect to remote device */ | 307 | /* Connect to remote device */ |
@@ -312,7 +312,7 @@ irnet_connect_tsap(irnet_socket * self) | |||
312 | { | 312 | { |
313 | clear_bit(0, &self->ttp_connect); | 313 | clear_bit(0, &self->ttp_connect); |
314 | DERROR(IRDA_SR_ERROR, "connect aborted!\n"); | 314 | DERROR(IRDA_SR_ERROR, "connect aborted!\n"); |
315 | return(err); | 315 | return err; |
316 | } | 316 | } |
317 | 317 | ||
318 | /* The above call is non-blocking. | 318 | /* The above call is non-blocking. |
@@ -321,7 +321,7 @@ irnet_connect_tsap(irnet_socket * self) | |||
321 | * See you there ;-) */ | 321 | * See you there ;-) */ |
322 | 322 | ||
323 | DEXIT(IRDA_SR_TRACE, "\n"); | 323 | DEXIT(IRDA_SR_TRACE, "\n"); |
324 | return(err); | 324 | return err; |
325 | } | 325 | } |
326 | 326 | ||
327 | /*------------------------------------------------------------------*/ | 327 | /*------------------------------------------------------------------*/ |
@@ -362,10 +362,10 @@ irnet_discover_next_daddr(irnet_socket * self) | |||
362 | /* The above request is non-blocking. | 362 | /* The above request is non-blocking. |
363 | * After a while, IrDA will call us back in irnet_discovervalue_confirm() | 363 | * After a while, IrDA will call us back in irnet_discovervalue_confirm() |
364 | * We will then call irnet_ias_to_tsap() and come back here again... */ | 364 | * We will then call irnet_ias_to_tsap() and come back here again... */ |
365 | return(0); | 365 | return 0; |
366 | } | 366 | } |
367 | else | 367 | else |
368 | return(1); | 368 | return 1; |
369 | } | 369 | } |
370 | 370 | ||
371 | /*------------------------------------------------------------------*/ | 371 | /*------------------------------------------------------------------*/ |
@@ -436,7 +436,7 @@ irnet_discover_daddr_and_lsap_sel(irnet_socket * self) | |||
436 | /* Follow me in irnet_discovervalue_confirm() */ | 436 | /* Follow me in irnet_discovervalue_confirm() */ |
437 | 437 | ||
438 | DEXIT(IRDA_SR_TRACE, "\n"); | 438 | DEXIT(IRDA_SR_TRACE, "\n"); |
439 | return(0); | 439 | return 0; |
440 | } | 440 | } |
441 | 441 | ||
442 | /*------------------------------------------------------------------*/ | 442 | /*------------------------------------------------------------------*/ |
@@ -485,7 +485,7 @@ irnet_dname_to_daddr(irnet_socket * self) | |||
485 | /* No luck ! */ | 485 | /* No luck ! */ |
486 | DEBUG(IRDA_SR_INFO, "cannot discover device ``%s'' !!!\n", self->rname); | 486 | DEBUG(IRDA_SR_INFO, "cannot discover device ``%s'' !!!\n", self->rname); |
487 | kfree(discoveries); | 487 | kfree(discoveries); |
488 | return(-EADDRNOTAVAIL); | 488 | return -EADDRNOTAVAIL; |
489 | } | 489 | } |
490 | 490 | ||
491 | 491 | ||
@@ -527,7 +527,7 @@ irda_irnet_create(irnet_socket * self) | |||
527 | INIT_WORK(&self->disconnect_work, irnet_ppp_disconnect); | 527 | INIT_WORK(&self->disconnect_work, irnet_ppp_disconnect); |
528 | 528 | ||
529 | DEXIT(IRDA_SOCK_TRACE, "\n"); | 529 | DEXIT(IRDA_SOCK_TRACE, "\n"); |
530 | return(0); | 530 | return 0; |
531 | } | 531 | } |
532 | 532 | ||
533 | /*------------------------------------------------------------------*/ | 533 | /*------------------------------------------------------------------*/ |
@@ -601,7 +601,7 @@ irda_irnet_connect(irnet_socket * self) | |||
601 | * We will finish the connection procedure in irnet_connect_tsap(). | 601 | * We will finish the connection procedure in irnet_connect_tsap(). |
602 | */ | 602 | */ |
603 | DEXIT(IRDA_SOCK_TRACE, "\n"); | 603 | DEXIT(IRDA_SOCK_TRACE, "\n"); |
604 | return(0); | 604 | return 0; |
605 | } | 605 | } |
606 | 606 | ||
607 | /*------------------------------------------------------------------*/ | 607 | /*------------------------------------------------------------------*/ |
@@ -733,7 +733,7 @@ irnet_daddr_to_dname(irnet_socket * self) | |||
733 | /* No luck ! */ | 733 | /* No luck ! */ |
734 | DEXIT(IRDA_SERV_INFO, ": cannot discover device 0x%08x !!!\n", self->daddr); | 734 | DEXIT(IRDA_SERV_INFO, ": cannot discover device 0x%08x !!!\n", self->daddr); |
735 | kfree(discoveries); | 735 | kfree(discoveries); |
736 | return(-EADDRNOTAVAIL); | 736 | return -EADDRNOTAVAIL; |
737 | } | 737 | } |
738 | 738 | ||
739 | /*------------------------------------------------------------------*/ | 739 | /*------------------------------------------------------------------*/ |
diff --git a/net/irda/irnet/irnet_ppp.c b/net/irda/irnet/irnet_ppp.c index dfe7b38dd4af..2bb2beb6a373 100644 --- a/net/irda/irnet/irnet_ppp.c +++ b/net/irda/irnet/irnet_ppp.c | |||
@@ -15,7 +15,6 @@ | |||
15 | 15 | ||
16 | #include <linux/sched.h> | 16 | #include <linux/sched.h> |
17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
18 | #include <linux/smp_lock.h> | ||
19 | #include "irnet_ppp.h" /* Private header */ | 18 | #include "irnet_ppp.h" /* Private header */ |
20 | /* Please put other headers in irnet.h - Thanks */ | 19 | /* Please put other headers in irnet.h - Thanks */ |
21 | 20 | ||
@@ -106,6 +105,9 @@ irnet_ctrl_write(irnet_socket * ap, | |||
106 | while(isspace(start[length - 1])) | 105 | while(isspace(start[length - 1])) |
107 | length--; | 106 | length--; |
108 | 107 | ||
108 | DABORT(length < 5 || length > NICKNAME_MAX_LEN + 5, | ||
109 | -EINVAL, CTRL_ERROR, "Invalid nickname.\n"); | ||
110 | |||
109 | /* Copy the name for later reuse */ | 111 | /* Copy the name for later reuse */ |
110 | memcpy(ap->rname, start + 5, length - 5); | 112 | memcpy(ap->rname, start + 5, length - 5); |
111 | ap->rname[length - 5] = '\0'; | 113 | ap->rname[length - 5] = '\0'; |
@@ -166,7 +168,7 @@ irnet_ctrl_write(irnet_socket * ap, | |||
166 | } | 168 | } |
167 | 169 | ||
168 | /* Success : we have parsed all commands successfully */ | 170 | /* Success : we have parsed all commands successfully */ |
169 | return(count); | 171 | return count; |
170 | } | 172 | } |
171 | 173 | ||
172 | #ifdef INITIAL_DISCOVERY | 174 | #ifdef INITIAL_DISCOVERY |
@@ -300,7 +302,7 @@ irnet_ctrl_read(irnet_socket * ap, | |||
300 | } | 302 | } |
301 | 303 | ||
302 | DEXIT(CTRL_TRACE, "\n"); | 304 | DEXIT(CTRL_TRACE, "\n"); |
303 | return(strlen(event)); | 305 | return strlen(event); |
304 | } | 306 | } |
305 | #endif /* INITIAL_DISCOVERY */ | 307 | #endif /* INITIAL_DISCOVERY */ |
306 | 308 | ||
@@ -409,7 +411,7 @@ irnet_ctrl_read(irnet_socket * ap, | |||
409 | } | 411 | } |
410 | 412 | ||
411 | DEXIT(CTRL_TRACE, "\n"); | 413 | DEXIT(CTRL_TRACE, "\n"); |
412 | return(strlen(event)); | 414 | return strlen(event); |
413 | } | 415 | } |
414 | 416 | ||
415 | /*------------------------------------------------------------------*/ | 417 | /*------------------------------------------------------------------*/ |
@@ -480,7 +482,6 @@ dev_irnet_open(struct inode * inode, | |||
480 | ap = kzalloc(sizeof(*ap), GFP_KERNEL); | 482 | ap = kzalloc(sizeof(*ap), GFP_KERNEL); |
481 | DABORT(ap == NULL, -ENOMEM, FS_ERROR, "Can't allocate struct irnet...\n"); | 483 | DABORT(ap == NULL, -ENOMEM, FS_ERROR, "Can't allocate struct irnet...\n"); |
482 | 484 | ||
483 | lock_kernel(); | ||
484 | /* initialize the irnet structure */ | 485 | /* initialize the irnet structure */ |
485 | ap->file = file; | 486 | ap->file = file; |
486 | 487 | ||
@@ -502,18 +503,20 @@ dev_irnet_open(struct inode * inode, | |||
502 | { | 503 | { |
503 | DERROR(FS_ERROR, "Can't setup IrDA link...\n"); | 504 | DERROR(FS_ERROR, "Can't setup IrDA link...\n"); |
504 | kfree(ap); | 505 | kfree(ap); |
505 | unlock_kernel(); | 506 | |
506 | return err; | 507 | return err; |
507 | } | 508 | } |
508 | 509 | ||
509 | /* For the control channel */ | 510 | /* For the control channel */ |
510 | ap->event_index = irnet_events.index; /* Cancel all past events */ | 511 | ap->event_index = irnet_events.index; /* Cancel all past events */ |
511 | 512 | ||
513 | mutex_init(&ap->lock); | ||
514 | |||
512 | /* Put our stuff where we will be able to find it later */ | 515 | /* Put our stuff where we will be able to find it later */ |
513 | file->private_data = ap; | 516 | file->private_data = ap; |
514 | 517 | ||
515 | DEXIT(FS_TRACE, " - ap=0x%p\n", ap); | 518 | DEXIT(FS_TRACE, " - ap=0x%p\n", ap); |
516 | unlock_kernel(); | 519 | |
517 | return 0; | 520 | return 0; |
518 | } | 521 | } |
519 | 522 | ||
@@ -623,7 +626,7 @@ dev_irnet_poll(struct file * file, | |||
623 | mask |= irnet_ctrl_poll(ap, file, wait); | 626 | mask |= irnet_ctrl_poll(ap, file, wait); |
624 | 627 | ||
625 | DEXIT(FS_TRACE, " - mask=0x%X\n", mask); | 628 | DEXIT(FS_TRACE, " - mask=0x%X\n", mask); |
626 | return(mask); | 629 | return mask; |
627 | } | 630 | } |
628 | 631 | ||
629 | /*------------------------------------------------------------------*/ | 632 | /*------------------------------------------------------------------*/ |
@@ -663,8 +666,10 @@ dev_irnet_ioctl( | |||
663 | if((val == N_SYNC_PPP) || (val == N_PPP)) | 666 | if((val == N_SYNC_PPP) || (val == N_PPP)) |
664 | { | 667 | { |
665 | DEBUG(FS_INFO, "Entering PPP discipline.\n"); | 668 | DEBUG(FS_INFO, "Entering PPP discipline.\n"); |
666 | /* PPP channel setup (ap->chan in configued in dev_irnet_open())*/ | 669 | /* PPP channel setup (ap->chan in configured in dev_irnet_open())*/ |
667 | lock_kernel(); | 670 | if (mutex_lock_interruptible(&ap->lock)) |
671 | return -EINTR; | ||
672 | |||
668 | err = ppp_register_channel(&ap->chan); | 673 | err = ppp_register_channel(&ap->chan); |
669 | if(err == 0) | 674 | if(err == 0) |
670 | { | 675 | { |
@@ -677,14 +682,17 @@ dev_irnet_ioctl( | |||
677 | } | 682 | } |
678 | else | 683 | else |
679 | DERROR(FS_ERROR, "Can't setup PPP channel...\n"); | 684 | DERROR(FS_ERROR, "Can't setup PPP channel...\n"); |
680 | unlock_kernel(); | 685 | |
686 | mutex_unlock(&ap->lock); | ||
681 | } | 687 | } |
682 | else | 688 | else |
683 | { | 689 | { |
684 | /* In theory, should be N_TTY */ | 690 | /* In theory, should be N_TTY */ |
685 | DEBUG(FS_INFO, "Exiting PPP discipline.\n"); | 691 | DEBUG(FS_INFO, "Exiting PPP discipline.\n"); |
686 | /* Disconnect from the generic PPP layer */ | 692 | /* Disconnect from the generic PPP layer */ |
687 | lock_kernel(); | 693 | if (mutex_lock_interruptible(&ap->lock)) |
694 | return -EINTR; | ||
695 | |||
688 | if(ap->ppp_open) | 696 | if(ap->ppp_open) |
689 | { | 697 | { |
690 | ap->ppp_open = 0; | 698 | ap->ppp_open = 0; |
@@ -693,24 +701,31 @@ dev_irnet_ioctl( | |||
693 | else | 701 | else |
694 | DERROR(FS_ERROR, "Channel not registered !\n"); | 702 | DERROR(FS_ERROR, "Channel not registered !\n"); |
695 | err = 0; | 703 | err = 0; |
696 | unlock_kernel(); | 704 | |
705 | mutex_unlock(&ap->lock); | ||
697 | } | 706 | } |
698 | break; | 707 | break; |
699 | 708 | ||
700 | /* Query PPP channel and unit number */ | 709 | /* Query PPP channel and unit number */ |
701 | case PPPIOCGCHAN: | 710 | case PPPIOCGCHAN: |
702 | lock_kernel(); | 711 | if (mutex_lock_interruptible(&ap->lock)) |
712 | return -EINTR; | ||
713 | |||
703 | if(ap->ppp_open && !put_user(ppp_channel_index(&ap->chan), | 714 | if(ap->ppp_open && !put_user(ppp_channel_index(&ap->chan), |
704 | (int __user *)argp)) | 715 | (int __user *)argp)) |
705 | err = 0; | 716 | err = 0; |
706 | unlock_kernel(); | 717 | |
718 | mutex_unlock(&ap->lock); | ||
707 | break; | 719 | break; |
708 | case PPPIOCGUNIT: | 720 | case PPPIOCGUNIT: |
709 | lock_kernel(); | 721 | if (mutex_lock_interruptible(&ap->lock)) |
722 | return -EINTR; | ||
723 | |||
710 | if(ap->ppp_open && !put_user(ppp_unit_number(&ap->chan), | 724 | if(ap->ppp_open && !put_user(ppp_unit_number(&ap->chan), |
711 | (int __user *)argp)) | 725 | (int __user *)argp)) |
712 | err = 0; | 726 | err = 0; |
713 | unlock_kernel(); | 727 | |
728 | mutex_unlock(&ap->lock); | ||
714 | break; | 729 | break; |
715 | 730 | ||
716 | /* All these ioctls can be passed both directly and from ppp_generic, | 731 | /* All these ioctls can be passed both directly and from ppp_generic, |
@@ -730,9 +745,12 @@ dev_irnet_ioctl( | |||
730 | if(!capable(CAP_NET_ADMIN)) | 745 | if(!capable(CAP_NET_ADMIN)) |
731 | err = -EPERM; | 746 | err = -EPERM; |
732 | else { | 747 | else { |
733 | lock_kernel(); | 748 | if (mutex_lock_interruptible(&ap->lock)) |
749 | return -EINTR; | ||
750 | |||
734 | err = ppp_irnet_ioctl(&ap->chan, cmd, arg); | 751 | err = ppp_irnet_ioctl(&ap->chan, cmd, arg); |
735 | unlock_kernel(); | 752 | |
753 | mutex_unlock(&ap->lock); | ||
736 | } | 754 | } |
737 | break; | 755 | break; |
738 | 756 | ||
@@ -740,7 +758,9 @@ dev_irnet_ioctl( | |||
740 | /* Get termios */ | 758 | /* Get termios */ |
741 | case TCGETS: | 759 | case TCGETS: |
742 | DEBUG(FS_INFO, "Get termios.\n"); | 760 | DEBUG(FS_INFO, "Get termios.\n"); |
743 | lock_kernel(); | 761 | if (mutex_lock_interruptible(&ap->lock)) |
762 | return -EINTR; | ||
763 | |||
744 | #ifndef TCGETS2 | 764 | #ifndef TCGETS2 |
745 | if(!kernel_termios_to_user_termios((struct termios __user *)argp, &ap->termios)) | 765 | if(!kernel_termios_to_user_termios((struct termios __user *)argp, &ap->termios)) |
746 | err = 0; | 766 | err = 0; |
@@ -748,12 +768,15 @@ dev_irnet_ioctl( | |||
748 | if(kernel_termios_to_user_termios_1((struct termios __user *)argp, &ap->termios)) | 768 | if(kernel_termios_to_user_termios_1((struct termios __user *)argp, &ap->termios)) |
749 | err = 0; | 769 | err = 0; |
750 | #endif | 770 | #endif |
751 | unlock_kernel(); | 771 | |
772 | mutex_unlock(&ap->lock); | ||
752 | break; | 773 | break; |
753 | /* Set termios */ | 774 | /* Set termios */ |
754 | case TCSETSF: | 775 | case TCSETSF: |
755 | DEBUG(FS_INFO, "Set termios.\n"); | 776 | DEBUG(FS_INFO, "Set termios.\n"); |
756 | lock_kernel(); | 777 | if (mutex_lock_interruptible(&ap->lock)) |
778 | return -EINTR; | ||
779 | |||
757 | #ifndef TCGETS2 | 780 | #ifndef TCGETS2 |
758 | if(!user_termios_to_kernel_termios(&ap->termios, (struct termios __user *)argp)) | 781 | if(!user_termios_to_kernel_termios(&ap->termios, (struct termios __user *)argp)) |
759 | err = 0; | 782 | err = 0; |
@@ -761,7 +784,8 @@ dev_irnet_ioctl( | |||
761 | if(!user_termios_to_kernel_termios_1(&ap->termios, (struct termios __user *)argp)) | 784 | if(!user_termios_to_kernel_termios_1(&ap->termios, (struct termios __user *)argp)) |
762 | err = 0; | 785 | err = 0; |
763 | #endif | 786 | #endif |
764 | unlock_kernel(); | 787 | |
788 | mutex_unlock(&ap->lock); | ||
765 | break; | 789 | break; |
766 | 790 | ||
767 | /* Set DTR/RTS */ | 791 | /* Set DTR/RTS */ |
@@ -784,9 +808,10 @@ dev_irnet_ioctl( | |||
784 | * We should also worry that we don't accept junk here and that | 808 | * We should also worry that we don't accept junk here and that |
785 | * we get rid of our own buffers */ | 809 | * we get rid of our own buffers */ |
786 | #ifdef FLUSH_TO_PPP | 810 | #ifdef FLUSH_TO_PPP |
787 | lock_kernel(); | 811 | if (mutex_lock_interruptible(&ap->lock)) |
812 | return -EINTR; | ||
788 | ppp_output_wakeup(&ap->chan); | 813 | ppp_output_wakeup(&ap->chan); |
789 | unlock_kernel(); | 814 | mutex_unlock(&ap->lock); |
790 | #endif /* FLUSH_TO_PPP */ | 815 | #endif /* FLUSH_TO_PPP */ |
791 | err = 0; | 816 | err = 0; |
792 | break; | 817 | break; |
diff --git a/net/irda/irnet/irnet_ppp.h b/net/irda/irnet/irnet_ppp.h index b5df2418f90c..940225866da0 100644 --- a/net/irda/irnet/irnet_ppp.h +++ b/net/irda/irnet/irnet_ppp.h | |||
@@ -103,7 +103,8 @@ static const struct file_operations irnet_device_fops = | |||
103 | .poll = dev_irnet_poll, | 103 | .poll = dev_irnet_poll, |
104 | .unlocked_ioctl = dev_irnet_ioctl, | 104 | .unlocked_ioctl = dev_irnet_ioctl, |
105 | .open = dev_irnet_open, | 105 | .open = dev_irnet_open, |
106 | .release = dev_irnet_close | 106 | .release = dev_irnet_close, |
107 | .llseek = noop_llseek, | ||
107 | /* Also : llseek, readdir, mmap, flush, fsync, fasync, lock, readv, writev */ | 108 | /* Also : llseek, readdir, mmap, flush, fsync, fasync, lock, readv, writev */ |
108 | }; | 109 | }; |
109 | 110 | ||
diff --git a/net/irda/irproc.c b/net/irda/irproc.c index 318766e5dbdf..b9ac598e2116 100644 --- a/net/irda/irproc.c +++ b/net/irda/irproc.c | |||
@@ -65,15 +65,14 @@ static const struct irda_entry irda_dirs[] = { | |||
65 | void __init irda_proc_register(void) | 65 | void __init irda_proc_register(void) |
66 | { | 66 | { |
67 | int i; | 67 | int i; |
68 | struct proc_dir_entry *d; | ||
69 | 68 | ||
70 | proc_irda = proc_mkdir("irda", init_net.proc_net); | 69 | proc_irda = proc_mkdir("irda", init_net.proc_net); |
71 | if (proc_irda == NULL) | 70 | if (proc_irda == NULL) |
72 | return; | 71 | return; |
73 | 72 | ||
74 | for (i = 0; i < ARRAY_SIZE(irda_dirs); i++) | 73 | for (i = 0; i < ARRAY_SIZE(irda_dirs); i++) |
75 | d = proc_create(irda_dirs[i].name, 0, proc_irda, | 74 | (void) proc_create(irda_dirs[i].name, 0, proc_irda, |
76 | irda_dirs[i].fops); | 75 | irda_dirs[i].fops); |
77 | } | 76 | } |
78 | 77 | ||
79 | /* | 78 | /* |
diff --git a/net/irda/irqueue.c b/net/irda/irqueue.c index 849aaf0dabb5..9715e6e5900b 100644 --- a/net/irda/irqueue.c +++ b/net/irda/irqueue.c | |||
@@ -40,7 +40,7 @@ | |||
40 | * o the hash function for ints is pathetic (but could be changed) | 40 | * o the hash function for ints is pathetic (but could be changed) |
41 | * o locking is sometime suspicious (especially during enumeration) | 41 | * o locking is sometime suspicious (especially during enumeration) |
42 | * o most users have only a few elements (== overhead) | 42 | * o most users have only a few elements (== overhead) |
43 | * o most users never use seach, so don't benefit from hashing | 43 | * o most users never use search, so don't benefit from hashing |
44 | * Problem already fixed : | 44 | * Problem already fixed : |
45 | * o not 64 bit compliant (most users do hashv = (int) self) | 45 | * o not 64 bit compliant (most users do hashv = (int) self) |
46 | * o hashbin_remove() is broken => use hashbin_remove_this() | 46 | * o hashbin_remove() is broken => use hashbin_remove_this() |
diff --git a/net/irda/irttp.c b/net/irda/irttp.c index 285761e77d90..9d9af4606970 100644 --- a/net/irda/irttp.c +++ b/net/irda/irttp.c | |||
@@ -550,22 +550,30 @@ EXPORT_SYMBOL(irttp_close_tsap); | |||
550 | */ | 550 | */ |
551 | int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb) | 551 | int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb) |
552 | { | 552 | { |
553 | int ret; | ||
554 | |||
553 | IRDA_ASSERT(self != NULL, return -1;); | 555 | IRDA_ASSERT(self != NULL, return -1;); |
554 | IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return -1;); | 556 | IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return -1;); |
555 | IRDA_ASSERT(skb != NULL, return -1;); | 557 | IRDA_ASSERT(skb != NULL, return -1;); |
556 | 558 | ||
557 | IRDA_DEBUG(4, "%s()\n", __func__); | 559 | IRDA_DEBUG(4, "%s()\n", __func__); |
558 | 560 | ||
561 | /* Take shortcut on zero byte packets */ | ||
562 | if (skb->len == 0) { | ||
563 | ret = 0; | ||
564 | goto err; | ||
565 | } | ||
566 | |||
559 | /* Check that nothing bad happens */ | 567 | /* Check that nothing bad happens */ |
560 | if ((skb->len == 0) || (!self->connected)) { | 568 | if (!self->connected) { |
561 | IRDA_DEBUG(1, "%s(), No data, or not connected\n", | 569 | IRDA_WARNING("%s(), Not connected\n", __func__); |
562 | __func__); | 570 | ret = -ENOTCONN; |
563 | goto err; | 571 | goto err; |
564 | } | 572 | } |
565 | 573 | ||
566 | if (skb->len > self->max_seg_size) { | 574 | if (skb->len > self->max_seg_size) { |
567 | IRDA_DEBUG(1, "%s(), UData is too large for IrLAP!\n", | 575 | IRDA_ERROR("%s(), UData is too large for IrLAP!\n", __func__); |
568 | __func__); | 576 | ret = -EMSGSIZE; |
569 | goto err; | 577 | goto err; |
570 | } | 578 | } |
571 | 579 | ||
@@ -576,7 +584,7 @@ int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb) | |||
576 | 584 | ||
577 | err: | 585 | err: |
578 | dev_kfree_skb(skb); | 586 | dev_kfree_skb(skb); |
579 | return -1; | 587 | return ret; |
580 | } | 588 | } |
581 | EXPORT_SYMBOL(irttp_udata_request); | 589 | EXPORT_SYMBOL(irttp_udata_request); |
582 | 590 | ||
@@ -599,9 +607,15 @@ int irttp_data_request(struct tsap_cb *self, struct sk_buff *skb) | |||
599 | IRDA_DEBUG(2, "%s() : queue len = %d\n", __func__, | 607 | IRDA_DEBUG(2, "%s() : queue len = %d\n", __func__, |
600 | skb_queue_len(&self->tx_queue)); | 608 | skb_queue_len(&self->tx_queue)); |
601 | 609 | ||
610 | /* Take shortcut on zero byte packets */ | ||
611 | if (skb->len == 0) { | ||
612 | ret = 0; | ||
613 | goto err; | ||
614 | } | ||
615 | |||
602 | /* Check that nothing bad happens */ | 616 | /* Check that nothing bad happens */ |
603 | if ((skb->len == 0) || (!self->connected)) { | 617 | if (!self->connected) { |
604 | IRDA_WARNING("%s: No data, or not connected\n", __func__); | 618 | IRDA_WARNING("%s: Not connected\n", __func__); |
605 | ret = -ENOTCONN; | 619 | ret = -ENOTCONN; |
606 | goto err; | 620 | goto err; |
607 | } | 621 | } |
@@ -1179,7 +1193,7 @@ EXPORT_SYMBOL(irttp_connect_request); | |||
1179 | /* | 1193 | /* |
1180 | * Function irttp_connect_confirm (handle, qos, skb) | 1194 | * Function irttp_connect_confirm (handle, qos, skb) |
1181 | * | 1195 | * |
1182 | * Sevice user confirms TSAP connection with peer. | 1196 | * Service user confirms TSAP connection with peer. |
1183 | * | 1197 | * |
1184 | */ | 1198 | */ |
1185 | static void irttp_connect_confirm(void *instance, void *sap, | 1199 | static void irttp_connect_confirm(void *instance, void *sap, |
diff --git a/net/irda/parameters.c b/net/irda/parameters.c index fc1a20565e2d..71cd38c1a67f 100644 --- a/net/irda/parameters.c +++ b/net/irda/parameters.c | |||
@@ -298,6 +298,8 @@ static int irda_extract_string(void *self, __u8 *buf, int len, __u8 pi, | |||
298 | 298 | ||
299 | p.pi = pi; /* In case handler needs to know */ | 299 | p.pi = pi; /* In case handler needs to know */ |
300 | p.pl = buf[1]; /* Extract length of value */ | 300 | p.pl = buf[1]; /* Extract length of value */ |
301 | if (p.pl > 32) | ||
302 | p.pl = 32; | ||
301 | 303 | ||
302 | IRDA_DEBUG(2, "%s(), pi=%#x, pl=%d\n", __func__, | 304 | IRDA_DEBUG(2, "%s(), pi=%#x, pl=%d\n", __func__, |
303 | p.pi, p.pl); | 305 | p.pi, p.pl); |
@@ -318,7 +320,7 @@ static int irda_extract_string(void *self, __u8 *buf, int len, __u8 pi, | |||
318 | (__u8) str[0], (__u8) str[1]); | 320 | (__u8) str[0], (__u8) str[1]); |
319 | 321 | ||
320 | /* Null terminate string */ | 322 | /* Null terminate string */ |
321 | str[p.pl+1] = '\0'; | 323 | str[p.pl] = '\0'; |
322 | 324 | ||
323 | p.pv.c = str; /* Handler will need to take a copy */ | 325 | p.pv.c = str; /* Handler will need to take a copy */ |
324 | 326 | ||
diff --git a/net/irda/qos.c b/net/irda/qos.c index 2b00974e5bae..1b51bcf42394 100644 --- a/net/irda/qos.c +++ b/net/irda/qos.c | |||
@@ -39,16 +39,16 @@ | |||
39 | #include <net/irda/irlap_frame.h> | 39 | #include <net/irda/irlap_frame.h> |
40 | 40 | ||
41 | /* | 41 | /* |
42 | * Maximum values of the baud rate we negociate with the other end. | 42 | * Maximum values of the baud rate we negotiate with the other end. |
43 | * Most often, you don't have to change that, because Linux-IrDA will | 43 | * Most often, you don't have to change that, because Linux-IrDA will |
44 | * use the maximum offered by the link layer, which usually works fine. | 44 | * use the maximum offered by the link layer, which usually works fine. |
45 | * In some very rare cases, you may want to limit it to lower speeds... | 45 | * In some very rare cases, you may want to limit it to lower speeds... |
46 | */ | 46 | */ |
47 | int sysctl_max_baud_rate = 16000000; | 47 | int sysctl_max_baud_rate = 16000000; |
48 | /* | 48 | /* |
49 | * Maximum value of the lap disconnect timer we negociate with the other end. | 49 | * Maximum value of the lap disconnect timer we negotiate with the other end. |
50 | * Most often, the value below represent the best compromise, but some user | 50 | * Most often, the value below represent the best compromise, but some user |
51 | * may want to keep the LAP alive longuer or shorter in case of link failure. | 51 | * may want to keep the LAP alive longer or shorter in case of link failure. |
52 | * Remember that the threshold time (early warning) is fixed to 3s... | 52 | * Remember that the threshold time (early warning) is fixed to 3s... |
53 | */ | 53 | */ |
54 | int sysctl_max_noreply_time = 12; | 54 | int sysctl_max_noreply_time = 12; |
@@ -411,7 +411,7 @@ static void irlap_adjust_qos_settings(struct qos_info *qos) | |||
411 | * Fix tx data size according to user limits - Jean II | 411 | * Fix tx data size according to user limits - Jean II |
412 | */ | 412 | */ |
413 | if (qos->data_size.value > sysctl_max_tx_data_size) | 413 | if (qos->data_size.value > sysctl_max_tx_data_size) |
414 | /* Allow non discrete adjustement to avoid loosing capacity */ | 414 | /* Allow non discrete adjustement to avoid losing capacity */ |
415 | qos->data_size.value = sysctl_max_tx_data_size; | 415 | qos->data_size.value = sysctl_max_tx_data_size; |
416 | /* | 416 | /* |
417 | * Override Tx window if user request it. - Jean II | 417 | * Override Tx window if user request it. - Jean II |
diff --git a/net/irda/timer.c b/net/irda/timer.c index 0335ba0cc593..f418cb2ad49c 100644 --- a/net/irda/timer.c +++ b/net/irda/timer.c | |||
@@ -59,7 +59,7 @@ void irlap_start_query_timer(struct irlap_cb *self, int S, int s) | |||
59 | * slot time, plus add some extra time to properly receive the last | 59 | * slot time, plus add some extra time to properly receive the last |
60 | * discovery packet (which is longer due to extra discovery info), | 60 | * discovery packet (which is longer due to extra discovery info), |
61 | * to avoid messing with for incomming connections requests and | 61 | * to avoid messing with for incomming connections requests and |
62 | * to accomodate devices that perform discovery slower than us. | 62 | * to accommodate devices that perform discovery slower than us. |
63 | * Jean II */ | 63 | * Jean II */ |
64 | timeout = ((sysctl_slot_timeout * HZ / 1000) * (S - s) | 64 | timeout = ((sysctl_slot_timeout * HZ / 1000) * (S - s) |
65 | + XIDEXTRA_TIMEOUT + SMALLBUSY_TIMEOUT); | 65 | + XIDEXTRA_TIMEOUT + SMALLBUSY_TIMEOUT); |