tun: Don't assume type tun in tun_device_event
[cascardo/linux.git] / drivers / net / tun.c
index 7475215..9c8b5bc 100644 (file)
@@ -1447,12 +1447,13 @@ static struct sk_buff *tun_ring_recv(struct tun_file *tfile, int noblock,
 {
        DECLARE_WAITQUEUE(wait, current);
        struct sk_buff *skb = NULL;
+       int error = 0;
 
        skb = skb_array_consume(&tfile->tx_array);
        if (skb)
                goto out;
        if (noblock) {
-               *err = -EAGAIN;
+               error = -EAGAIN;
                goto out;
        }
 
@@ -1464,11 +1465,11 @@ static struct sk_buff *tun_ring_recv(struct tun_file *tfile, int noblock,
                if (skb)
                        break;
                if (signal_pending(current)) {
-                       *err = -ERESTARTSYS;
+                       error = -ERESTARTSYS;
                        break;
                }
                if (tfile->socket.sk->sk_shutdown & RCV_SHUTDOWN) {
-                       *err = -EFAULT;
+                       error = -EFAULT;
                        break;
                }
 
@@ -1479,6 +1480,7 @@ static struct sk_buff *tun_ring_recv(struct tun_file *tfile, int noblock,
        remove_wait_queue(&tfile->wq.wait, &wait);
 
 out:
+       *err = error;
        return skb;
 }
 
@@ -2501,6 +2503,9 @@ static int tun_device_event(struct notifier_block *unused,
        struct net_device *dev = netdev_notifier_info_to_dev(ptr);
        struct tun_struct *tun = netdev_priv(dev);
 
+       if (dev->rtnl_link_ops != &tun_link_ops)
+               return NOTIFY_DONE;
+
        switch (event) {
        case NETDEV_CHANGE_TX_QUEUE_LEN:
                if (tun_queue_resize(tun))