Skip to content

Commit

Permalink
[AF_PACKET]: Check device down state before hard header callbacks.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David S. Miller committed Jan 26, 2007
1 parent 95743de commit d5e76b0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions net/packet/af_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -738,6 +738,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;
Expand Down Expand Up @@ -770,10 +774,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
*/
Expand Down

0 comments on commit d5e76b0

Please sign in to comment.