Subject: [PATCH] vlan: fix vlan_skb_recv()

From: Eric Dumazet <[email-masked]>
Date: Sun, 24 Jan 2010 20:43:06 +0100

Le 24/01/2010 20:18, Bruno Prémont a écrit :
> Yep, works fine and RX stats look right as well.
> 
> So
> Reported-By: Bruno Prémont <[email-masked]>
> Tested-By: Bruno Prémont <[email-masked]>
> 
> Thanks,

Thanks very much Bruno, here is the official patch submission then.

[PATCH] vlan: fix vlan_skb_recv()

Bruno Prémont found commit 9793241fe92f7d930
(vlan: Precise RX stats accounting) added a regression for non
hw accelerated vlans.

[   26.390576] BUG: unable to handle kernel NULL pointer dereference at (null)
[   26.396369] IP: [<df856b89>] vlan_skb_recv+0x89/0x280 [8021q]

vlan_dev_info() was used with original device, instead of
skb->dev. Also spotted by Américo Wang.

Reported-By: Bruno Prémont <[email-masked]>
Tested-By: Bruno Prémont <[email-masked]>
Signed-off-by: Eric Dumazet <[email-masked]>
---
 net/8021q/vlan_dev.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index b788978..c1b92ca 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -163,7 +163,7 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
 		goto err_unlock;
 	}
 
-	rx_stats = per_cpu_ptr(vlan_dev_info(dev)->vlan_rx_stats,
+	rx_stats = per_cpu_ptr(vlan_dev_info(skb->dev)->vlan_rx_stats,
 			       smp_processor_id());
 	rx_stats->rx_packets++;
 	rx_stats->rx_bytes += skb->len;