]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
AF_PACKET: Check device down state before hard header callbacks.
authorDavid S. Miller <davem@davemloft.net>
Wed, 14 Feb 2007 08:25:18 +0000 (09:25 +0100)
committerAdrian Bunk <bunk@stusta.de>
Wed, 14 Feb 2007 08:25:18 +0000 (09:25 +0100)
If the device is down, invoking the device hard header callbacks
is not legal, so check it early.

Based upon a shaper OOPS report from Frederik Deweerdt.

Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
net/packet/af_packet.c

index 9db7dbdb16e6bd14c7ca23dc6c8dfe11e16f4566..229126a1af634c85a0f7a989d2851c3d9743ff5f 100644 (file)
@@ -359,6 +359,10 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
        if (dev == NULL)
                goto out_unlock;
        
+       err = -ENETDOWN;
+       if (!(dev->flags & IFF_UP))
+               goto out_unlock;
+
        /*
         *      You may not queue a frame bigger than the mtu. This is the lowest level
         *      raw protocol and you must do your own fragmentation at this level.
@@ -407,10 +411,6 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
        if (err)
                goto out_free;
 
-       err = -ENETDOWN;
-       if (!(dev->flags & IFF_UP))
-               goto out_free;
-
        /*
         *      Now send it
         */
@@ -747,6 +747,10 @@ static int packet_sendmsg(struct kiocb *iocb, struct socket *sock,
        if (sock->type == SOCK_RAW)
                reserve = dev->hard_header_len;
 
+       err = -ENETDOWN;
+       if (!(dev->flags & IFF_UP))
+               goto out_unlock;
+
        err = -EMSGSIZE;
        if (len > dev->mtu+reserve)
                goto out_unlock;
@@ -779,10 +783,6 @@ static int packet_sendmsg(struct kiocb *iocb, struct socket *sock,
        skb->dev = dev;
        skb->priority = sk->sk_priority;
 
-       err = -ENETDOWN;
-       if (!(dev->flags & IFF_UP))
-               goto out_free;
-
        /*
         *      Now send it
         */