···10611061 return -EOPNOTSUPP;10621062}1063106310641064+/* If command is `set a parameter', or `get the encoding parameters',10651065+ * check if the user has the right to do it.10661066+ */10671067+static int wext_permission_check(unsigned int cmd)10681068+{10691069+ if ((IW_IS_SET(cmd) || cmd == SIOCGIWENCODE || cmd == SIOCGIWENCODEEXT)10701070+ && !capable(CAP_NET_ADMIN))10711071+ return -EPERM;10721072+10731073+ return 0;10741074+}10751075+10641076/* entry point from dev ioctl */10651077int wext_handle_ioctl(struct net *net, struct ifreq *ifr, unsigned int cmd,10661078 void __user *arg)10671079{10681068- int ret;10801080+ int ret = wext_permission_check(cmd);1069108110701070- /* If command is `set a parameter', or10711071- * `get the encoding parameters', check if10721072- * the user has the right to do it */10731073- if ((IW_IS_SET(cmd) || cmd == SIOCGIWENCODE || cmd == SIOCGIWENCODEEXT)10741074- && !capable(CAP_NET_ADMIN))10751075- return -EPERM;10821082+ if (ret)10831083+ return ret;1076108410771085 dev_load(net, ifr->ifr_name);10781086 rtnl_lock();