OSDN Git Service

Merge 4.4.168 into android-4.4
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / drivers / net / tun.c
index d5fc7f4..6032ec8 100644 (file)
@@ -1472,7 +1472,9 @@ static void tun_setup(struct net_device *dev)
  */
 static int tun_validate(struct nlattr *tb[], struct nlattr *data[])
 {
-       return -EINVAL;
+       /* NL_SET_ERR_MSG(extack,
+                      "tun/tap creation via rtnetlink is not supported."); */
+       return -EOPNOTSUPP;
 }
 
 static struct rtnl_link_ops tun_link_ops __read_mostly = {
@@ -1681,6 +1683,9 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
 
                if (!dev)
                        return -ENOMEM;
+               err = dev_get_valid_name(net, dev, name);
+               if (err < 0)
+                       goto err_free_dev;
 
                dev_net_set(dev, net);
                dev->rtnl_link_ops = &tun_link_ops;
@@ -2068,6 +2073,10 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
                        ret = -EFAULT;
                        break;
                }
+               if (sndbuf <= 0) {
+                       ret = -EINVAL;
+                       break;
+               }
 
                tun->sndbuf = sndbuf;
                tun_set_sndbuf(tun);