Commit 5ff7630e authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David S. Miller

[NETROM]: Remove unessecary lock_sock calls in netrom_ioctl()

lock_sock is needed only in very few cases, so do it there instead of
around the switch statement.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b461d2f2
...@@ -1166,10 +1166,11 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -1166,10 +1166,11 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
void __user *argp = (void __user *)arg; void __user *argp = (void __user *)arg;
int ret; int ret;
lock_sock(sk);
switch (cmd) { switch (cmd) {
case TIOCOUTQ: { case TIOCOUTQ: {
long amount; long amount;
lock_sock(sk);
amount = sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc); amount = sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc);
if (amount < 0) if (amount < 0)
amount = 0; amount = 0;
...@@ -1180,6 +1181,8 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -1180,6 +1181,8 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
case TIOCINQ: { case TIOCINQ: {
struct sk_buff *skb; struct sk_buff *skb;
long amount = 0L; long amount = 0L;
lock_sock(sk);
/* These two are safe on a single CPU system as only user tasks fiddle here */ /* These two are safe on a single CPU system as only user tasks fiddle here */
if ((skb = skb_peek(&sk->sk_receive_queue)) != NULL) if ((skb = skb_peek(&sk->sk_receive_queue)) != NULL)
amount = skb->len; amount = skb->len;
...@@ -1188,6 +1191,7 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -1188,6 +1191,7 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
} }
case SIOCGSTAMP: case SIOCGSTAMP:
lock_sock(sk);
ret = sock_get_timestamp(sk, argp); ret = sock_get_timestamp(sk, argp);
release_sock(sk); release_sock(sk);
return ret; return ret;
...@@ -1202,21 +1206,17 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -1202,21 +1206,17 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
case SIOCSIFNETMASK: case SIOCSIFNETMASK:
case SIOCGIFMETRIC: case SIOCGIFMETRIC:
case SIOCSIFMETRIC: case SIOCSIFMETRIC:
release_sock(sk);
return -EINVAL; return -EINVAL;
case SIOCADDRT: case SIOCADDRT:
case SIOCDELRT: case SIOCDELRT:
case SIOCNRDECOBS: case SIOCNRDECOBS:
release_sock(sk);
if (!capable(CAP_NET_ADMIN)) return -EPERM; if (!capable(CAP_NET_ADMIN)) return -EPERM;
return nr_rt_ioctl(cmd, argp); return nr_rt_ioctl(cmd, argp);
default: default:
release_sock(sk);
return dev_ioctl(cmd, argp); return dev_ioctl(cmd, argp);
} }
release_sock(sk);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment