Merge tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[cascardo/linux.git] / drivers / net / macvtap.c
index 9724301..59e9605 100644 (file)
@@ -279,28 +279,17 @@ static int macvtap_receive(struct sk_buff *skb)
 static int macvtap_get_minor(struct macvlan_dev *vlan)
 {
        int retval = -ENOMEM;
-       int id;
 
        mutex_lock(&minor_lock);
-       if (idr_pre_get(&minor_idr, GFP_KERNEL) == 0)
-               goto exit;
-
-       retval = idr_get_new_above(&minor_idr, vlan, 1, &id);
-       if (retval < 0) {
-               if (retval == -EAGAIN)
-                       retval = -ENOMEM;
-               goto exit;
-       }
-       if (id < MACVTAP_NUM_DEVS) {
-               vlan->minor = id;
-       } else {
+       retval = idr_alloc(&minor_idr, vlan, 1, MACVTAP_NUM_DEVS, GFP_KERNEL);
+       if (retval >= 0) {
+               vlan->minor = retval;
+       } else if (retval == -ENOSPC) {
                printk(KERN_ERR "too many macvtap devices\n");
                retval = -EINVAL;
-               idr_remove(&minor_idr, id);
        }
-exit:
        mutex_unlock(&minor_lock);
-       return retval;
+       return retval < 0 ? retval : 0;
 }
 
 static void macvtap_free_minor(struct macvlan_dev *vlan)
@@ -736,6 +725,8 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
                        goto err_kfree;
        }
 
+       skb_probe_transport_header(skb, ETH_HLEN);
+
        rcu_read_lock_bh();
        vlan = rcu_dereference_bh(q->vlan);
        /* copy skb_ubuf_info for callback when skb has no error */