diff options
author | David S. Miller <davem@sunset.davemloft.net> | 2007-01-25 22:30:36 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-01-25 22:30:36 -0500 |
commit | d5e76b0a280f71b20bdd20d1c1b4d6812ceb8c3a (patch) | |
tree | 66241edf73d49e78cc85c0123178fb56b551a282 /net | |
parent | 95743deb34de29defbb98ad477700aaf344f93f3 (diff) |
[AF_PACKET]: Check device down state before hard header callbacks.
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>
Diffstat (limited to 'net')
-rw-r--r-- | net/packet/af_packet.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 594c078c5ebc..6dc01bdeb76b 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -359,6 +359,10 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock, | |||
359 | if (dev == NULL) | 359 | if (dev == NULL) |
360 | goto out_unlock; | 360 | goto out_unlock; |
361 | 361 | ||
362 | err = -ENETDOWN; | ||
363 | if (!(dev->flags & IFF_UP)) | ||
364 | goto out_unlock; | ||
365 | |||
362 | /* | 366 | /* |
363 | * You may not queue a frame bigger than the mtu. This is the lowest level | 367 | * You may not queue a frame bigger than the mtu. This is the lowest level |
364 | * raw protocol and you must do your own fragmentation at this level. | 368 | * 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, | |||
407 | if (err) | 411 | if (err) |
408 | goto out_free; | 412 | goto out_free; |
409 | 413 | ||
410 | err = -ENETDOWN; | ||
411 | if (!(dev->flags & IFF_UP)) | ||
412 | goto out_free; | ||
413 | |||
414 | /* | 414 | /* |
415 | * Now send it | 415 | * Now send it |
416 | */ | 416 | */ |
@@ -738,6 +738,10 @@ static int packet_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
738 | if (sock->type == SOCK_RAW) | 738 | if (sock->type == SOCK_RAW) |
739 | reserve = dev->hard_header_len; | 739 | reserve = dev->hard_header_len; |
740 | 740 | ||
741 | err = -ENETDOWN; | ||
742 | if (!(dev->flags & IFF_UP)) | ||
743 | goto out_unlock; | ||
744 | |||
741 | err = -EMSGSIZE; | 745 | err = -EMSGSIZE; |
742 | if (len > dev->mtu+reserve) | 746 | if (len > dev->mtu+reserve) |
743 | goto out_unlock; | 747 | goto out_unlock; |
@@ -770,10 +774,6 @@ static int packet_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
770 | skb->dev = dev; | 774 | skb->dev = dev; |
771 | skb->priority = sk->sk_priority; | 775 | skb->priority = sk->sk_priority; |
772 | 776 | ||
773 | err = -ENETDOWN; | ||
774 | if (!(dev->flags & IFF_UP)) | ||
775 | goto out_free; | ||
776 | |||
777 | /* | 777 | /* |
778 | * Now send it | 778 | * Now send it |
779 | */ | 779 | */ |