diff mbox

[4/4] pch_gbe: vlan skb len fix

Message ID 40680C535D6FE6498883F1640FACD44D010BFC0E@ka-exchange-1.kontronamerica.local
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Andy Cress July 9, 2012, 1:30 p.m. UTC
Author: Veaceslav Falico <vfalico@redhat.com>
Date:   Tue Apr 10 08:14:17 2012 +0200

    pch_gbe: correctly verify skb->len in vlan case
             to avoid bogus transfer length errors.

Signed-off-by: Andy Cress <andy.cress@us.kontron.com>

 		       skb->len, adapter->hw.mac.max_frame_size);
 		dev_kfree_skb_any(skb);
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Ben Hutchings July 9, 2012, 8:33 p.m. UTC | #1
On Mon, 2012-07-09 at 06:30 -0700, Andy Cress wrote:
> Author: Veaceslav Falico <vfalico@redhat.com>
> Date:   Tue Apr 10 08:14:17 2012 +0200
> 
>     pch_gbe: correctly verify skb->len in vlan case
>              to avoid bogus transfer length errors.

This check shouldn't be necessary at all.  Maybe you should remove it
instead of correcting the check?

Also, these patches are word-wrapped, and would not be applicable in
this form.  See Documentation/email-clients.txt.

Ben.

> Signed-off-by: Andy Cress <andy.cress@us.kontron.com>
> 
> diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
> b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
> index 30ef285..04b0e49 100644
> --- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
> +++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
> @@ -2158,8 +2158,10 @@ static int pch_gbe_xmit_frame(struct sk_buff
> *skb, struct net_device *netdev)
>  	struct pch_gbe_adapter *adapter = netdev_priv(netdev);
>  	struct pch_gbe_tx_ring *tx_ring = adapter->tx_ring;
>  	unsigned long flags;
> +	int offset;
>  
> -	if (unlikely(skb->len > (adapter->hw.mac.max_frame_size - 4))) {
> +	offset = skb->protocol == htons(ETH_P_8021Q) ? 0 : 4;
> +	if (unlikely(skb->len > (adapter->hw.mac.max_frame_size -
> offset))) {
>  		pr_err("Transfer length Error: skb len: %d > max: %d\n",
>  		       skb->len, adapter->hw.mac.max_frame_size);
>  		dev_kfree_skb_any(skb);
diff mbox

Patch

diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index 30ef285..04b0e49 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -2158,8 +2158,10 @@  static int pch_gbe_xmit_frame(struct sk_buff
*skb, struct net_device *netdev)
 	struct pch_gbe_adapter *adapter = netdev_priv(netdev);
 	struct pch_gbe_tx_ring *tx_ring = adapter->tx_ring;
 	unsigned long flags;
+	int offset;
 
-	if (unlikely(skb->len > (adapter->hw.mac.max_frame_size - 4))) {
+	offset = skb->protocol == htons(ETH_P_8021Q) ? 0 : 4;
+	if (unlikely(skb->len > (adapter->hw.mac.max_frame_size -
offset))) {
 		pr_err("Transfer length Error: skb len: %d > max: %d\n",