[PPPoE]: move lock_sock() in pppoe_sendmsg() to the right location
[cascardo/linux.git] / drivers / net / pppoe.c
index 6f98834..35a7385 100644 (file)
@@ -664,8 +664,8 @@ static int pppoe_ioctl(struct socket *sock, unsigned int cmd,
 {
        struct sock *sk = sock->sk;
        struct pppox_sock *po = pppox_sk(sk);
-       int val = 0;
-       int err = 0;
+       int val;
+       int err;
 
        switch (cmd) {
        case PPPIOCGMRU:
@@ -754,8 +754,9 @@ static int pppoe_ioctl(struct socket *sock, unsigned int cmd,
                err = 0;
                break;
 
-       default:;
-       };
+       default:
+               err = -ENOTTY;
+       }
 
        return err;
 }
@@ -773,6 +774,7 @@ static int pppoe_sendmsg(struct kiocb *iocb, struct socket *sock,
        struct net_device *dev;
        char *start;
 
+       lock_sock(sk);
        if (sock_flag(sk, SOCK_DEAD) || !(sk->sk_state & PPPOX_CONNECTED)) {
                error = -ENOTCONN;
                goto end;
@@ -783,8 +785,6 @@ static int pppoe_sendmsg(struct kiocb *iocb, struct socket *sock,
        hdr.code = 0;
        hdr.sid = po->num;
 
-       lock_sock(sk);
-
        dev = po->pppoe_dev;
 
        error = -EMSGSIZE;