From 1894c622c053c8790a756b82ee14493435da2393 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Sun, 26 Oct 2003 07:52:27 -0800 Subject: [PATCH] [NET]: Fix oops in ethertap_rx(). --- drivers/net/ethertap.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethertap.c b/drivers/net/ethertap.c index 0656fefa9670e..7f4f4ae8c5c62 100644 --- a/drivers/net/ethertap.c +++ b/drivers/net/ethertap.c @@ -302,11 +302,12 @@ static __inline__ int ethertap_rx_skb(struct sk_buff *skb, struct net_device *de static void ethertap_rx(struct sock *sk, int len) { - struct net_device *dev = tap_map[sk->sk_protocol]; + unsigned unit = sk->sk_protocol - NETLINK_TAPBASE; + struct net_device *dev; struct sk_buff *skb; - if (dev==NULL) { - printk(KERN_CRIT "ethertap: bad unit!\n"); + if (unit >= max_taps || (dev = tap_map[unit]) == NULL) { + printk(KERN_CRIT "ethertap: bad unit %u!\n", unit); skb_queue_purge(&sk->sk_receive_queue); return; } -- 2.53.0