summaryrefslogtreecommitdiffstats
path: root/net/wireless
diff options
context:
space:
mode:
authorDavid S. Miller <davem@sunset.davemloft.net>2007-12-21 12:36:31 +0100
committerDavid S. Miller <davem@davemloft.net>2008-06-17 03:30:47 +0200
commit67dd7608078b17f63f29ff2108fc5bf2407ddcec (patch)
tree92dda0580609f2be16c45e9c8bdbaed0d1fb5a00 /net/wireless
parentwext: Extract private call iw_point handling into seperate functions. (diff)
downloadlinux-67dd7608078b17f63f29ff2108fc5bf2407ddcec.tar.xz
linux-67dd7608078b17f63f29ff2108fc5bf2407ddcec.zip
wext: Pull ioctl permission checking out into helper function.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/wireless')
-rw-r--r--net/wireless/wext.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/net/wireless/wext.c b/net/wireless/wext.c
index a1cd19add6d8..e96559ea0fb3 100644
--- a/net/wireless/wext.c
+++ b/net/wireless/wext.c
@@ -1061,18 +1061,26 @@ static int wireless_process_ioctl(struct net *net, struct ifreq *ifr, unsigned i
return -EOPNOTSUPP;
}
+/* If command is `set a parameter', or `get the encoding parameters',
+ * check if the user has the right to do it.
+ */
+static int wext_permission_check(unsigned int cmd)
+{
+ if ((IW_IS_SET(cmd) || cmd == SIOCGIWENCODE || cmd == SIOCGIWENCODEEXT)
+ && !capable(CAP_NET_ADMIN))
+ return -EPERM;
+
+ return 0;
+}
+
/* entry point from dev ioctl */
int wext_handle_ioctl(struct net *net, struct ifreq *ifr, unsigned int cmd,
void __user *arg)
{
- int ret;
+ int ret = wext_permission_check(cmd);
- /* If command is `set a parameter', or
- * `get the encoding parameters', check if
- * the user has the right to do it */
- if ((IW_IS_SET(cmd) || cmd == SIOCGIWENCODE || cmd == SIOCGIWENCODEEXT)
- && !capable(CAP_NET_ADMIN))
- return -EPERM;
+ if (ret)
+ return ret;
dev_load(net, ifr->ifr_name);
rtnl_lock();