aboutsummaryrefslogtreecommitdiffstats
path: root/net/appletalk/ddp.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2011-01-22 18:21:11 -0500
committerArnd Bergmann <arnd@arndb.de>2011-03-05 04:55:57 -0500
commit60d9f461a20ba59219fdcdc30cbf8e3a4ad3f625 (patch)
tree1b6b03505a435172932869bdc0a966d62c560985 /net/appletalk/ddp.c
parent77b2283604bdd7053494a97b0e2fee97148206c6 (diff)
appletalk: remove the BKL
This changes appletalk to use lock_sock instead of lock_kernel for serialization. I tried to make sure that we don't hold the socket lock during sleeping functions, but I did not try to prove whether the locks are necessary in the first place. Compile-tested only. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: David S. Miller <davem@davemloft.net> Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net> Cc: David Miller <davem@davemloft.net> Cc: netdev@vger.kernel.org
Diffstat (limited to 'net/appletalk/ddp.c')
-rw-r--r--net/appletalk/ddp.c40
1 files changed, 16 insertions, 24 deletions
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index c410b93fda2e..3d4f4b043406 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -54,7 +54,6 @@
54#include <linux/capability.h> 54#include <linux/capability.h>
55#include <linux/module.h> 55#include <linux/module.h>
56#include <linux/if_arp.h> 56#include <linux/if_arp.h>
57#include <linux/smp_lock.h>
58#include <linux/termios.h> /* For TIOCOUTQ/INQ */ 57#include <linux/termios.h> /* For TIOCOUTQ/INQ */
59#include <linux/compat.h> 58#include <linux/compat.h>
60#include <linux/slab.h> 59#include <linux/slab.h>
@@ -1052,13 +1051,13 @@ static int atalk_release(struct socket *sock)
1052{ 1051{
1053 struct sock *sk = sock->sk; 1052 struct sock *sk = sock->sk;
1054 1053
1055 lock_kernel(); 1054 lock_sock(sk);
1056 if (sk) { 1055 if (sk) {
1057 sock_orphan(sk); 1056 sock_orphan(sk);
1058 sock->sk = NULL; 1057 sock->sk = NULL;
1059 atalk_destroy_socket(sk); 1058 atalk_destroy_socket(sk);
1060 } 1059 }
1061 unlock_kernel(); 1060 release_sock(sk);
1062 return 0; 1061 return 0;
1063} 1062}
1064 1063
@@ -1143,7 +1142,7 @@ static int atalk_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
1143 if (addr->sat_family != AF_APPLETALK) 1142 if (addr->sat_family != AF_APPLETALK)
1144 return -EAFNOSUPPORT; 1143 return -EAFNOSUPPORT;
1145 1144
1146 lock_kernel(); 1145 lock_sock(sk);
1147 if (addr->sat_addr.s_net == htons(ATADDR_ANYNET)) { 1146 if (addr->sat_addr.s_net == htons(ATADDR_ANYNET)) {
1148 struct atalk_addr *ap = atalk_find_primary(); 1147 struct atalk_addr *ap = atalk_find_primary();
1149 1148
@@ -1179,7 +1178,7 @@ static int atalk_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
1179 sock_reset_flag(sk, SOCK_ZAPPED); 1178 sock_reset_flag(sk, SOCK_ZAPPED);
1180 err = 0; 1179 err = 0;
1181out: 1180out:
1182 unlock_kernel(); 1181 release_sock(sk);
1183 return err; 1182 return err;
1184} 1183}
1185 1184
@@ -1215,7 +1214,7 @@ static int atalk_connect(struct socket *sock, struct sockaddr *uaddr,
1215#endif 1214#endif
1216 } 1215 }
1217 1216
1218 lock_kernel(); 1217 lock_sock(sk);
1219 err = -EBUSY; 1218 err = -EBUSY;
1220 if (sock_flag(sk, SOCK_ZAPPED)) 1219 if (sock_flag(sk, SOCK_ZAPPED))
1221 if (atalk_autobind(sk) < 0) 1220 if (atalk_autobind(sk) < 0)
@@ -1233,7 +1232,7 @@ static int atalk_connect(struct socket *sock, struct sockaddr *uaddr,
1233 sk->sk_state = TCP_ESTABLISHED; 1232 sk->sk_state = TCP_ESTABLISHED;
1234 err = 0; 1233 err = 0;
1235out: 1234out:
1236 unlock_kernel(); 1235 release_sock(sk);
1237 return err; 1236 return err;
1238} 1237}
1239 1238
@@ -1249,7 +1248,7 @@ static int atalk_getname(struct socket *sock, struct sockaddr *uaddr,
1249 struct atalk_sock *at = at_sk(sk); 1248 struct atalk_sock *at = at_sk(sk);
1250 int err; 1249 int err;
1251 1250
1252 lock_kernel(); 1251 lock_sock(sk);
1253 err = -ENOBUFS; 1252 err = -ENOBUFS;
1254 if (sock_flag(sk, SOCK_ZAPPED)) 1253 if (sock_flag(sk, SOCK_ZAPPED))
1255 if (atalk_autobind(sk) < 0) 1254 if (atalk_autobind(sk) < 0)
@@ -1277,17 +1276,7 @@ static int atalk_getname(struct socket *sock, struct sockaddr *uaddr,
1277 memcpy(uaddr, &sat, sizeof(sat)); 1276 memcpy(uaddr, &sat, sizeof(sat));
1278 1277
1279out: 1278out:
1280 unlock_kernel(); 1279 release_sock(sk);
1281 return err;
1282}
1283
1284static unsigned int atalk_poll(struct file *file, struct socket *sock,
1285 poll_table *wait)
1286{
1287 int err;
1288 lock_kernel();
1289 err = datagram_poll(file, sock, wait);
1290 unlock_kernel();
1291 return err; 1280 return err;
1292} 1281}
1293 1282
@@ -1596,7 +1585,7 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
1596 if (len > DDP_MAXSZ) 1585 if (len > DDP_MAXSZ)
1597 return -EMSGSIZE; 1586 return -EMSGSIZE;
1598 1587
1599 lock_kernel(); 1588 lock_sock(sk);
1600 if (usat) { 1589 if (usat) {
1601 err = -EBUSY; 1590 err = -EBUSY;
1602 if (sock_flag(sk, SOCK_ZAPPED)) 1591 if (sock_flag(sk, SOCK_ZAPPED))
@@ -1651,7 +1640,9 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
1651 sk, size, dev->name); 1640 sk, size, dev->name);
1652 1641
1653 size += dev->hard_header_len; 1642 size += dev->hard_header_len;
1643 release_sock(sk);
1654 skb = sock_alloc_send_skb(sk, size, (flags & MSG_DONTWAIT), &err); 1644 skb = sock_alloc_send_skb(sk, size, (flags & MSG_DONTWAIT), &err);
1645 lock_sock(sk);
1655 if (!skb) 1646 if (!skb)
1656 goto out; 1647 goto out;
1657 1648
@@ -1738,7 +1729,7 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
1738 SOCK_DEBUG(sk, "SK %p: Done write (%Zd).\n", sk, len); 1729 SOCK_DEBUG(sk, "SK %p: Done write (%Zd).\n", sk, len);
1739 1730
1740out: 1731out:
1741 unlock_kernel(); 1732 release_sock(sk);
1742 return err ? : len; 1733 return err ? : len;
1743} 1734}
1744 1735
@@ -1753,9 +1744,10 @@ static int atalk_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
1753 int err = 0; 1744 int err = 0;
1754 struct sk_buff *skb; 1745 struct sk_buff *skb;
1755 1746
1756 lock_kernel();
1757 skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, 1747 skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,
1758 flags & MSG_DONTWAIT, &err); 1748 flags & MSG_DONTWAIT, &err);
1749 lock_sock(sk);
1750
1759 if (!skb) 1751 if (!skb)
1760 goto out; 1752 goto out;
1761 1753
@@ -1787,7 +1779,7 @@ static int atalk_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
1787 skb_free_datagram(sk, skb); /* Free the datagram. */ 1779 skb_free_datagram(sk, skb); /* Free the datagram. */
1788 1780
1789out: 1781out:
1790 unlock_kernel(); 1782 release_sock(sk);
1791 return err ? : copied; 1783 return err ? : copied;
1792} 1784}
1793 1785
@@ -1887,7 +1879,7 @@ static const struct proto_ops atalk_dgram_ops = {
1887 .socketpair = sock_no_socketpair, 1879 .socketpair = sock_no_socketpair,
1888 .accept = sock_no_accept, 1880 .accept = sock_no_accept,
1889 .getname = atalk_getname, 1881 .getname = atalk_getname,
1890 .poll = atalk_poll, 1882 .poll = datagram_poll,
1891 .ioctl = atalk_ioctl, 1883 .ioctl = atalk_ioctl,
1892#ifdef CONFIG_COMPAT 1884#ifdef CONFIG_COMPAT
1893 .compat_ioctl = atalk_compat_ioctl, 1885 .compat_ioctl = atalk_compat_ioctl,