[patch 29/37] tun: Return -EINVAL if neither IFF_TUN nor IFF_TAP is set.

Greg KH
2009-10-09T23:42:15Z

[-- Attachment #1: tun-return-einval-if-neither-iff_tun-nor-iff_tap-is-set.patch --]
[-- Type: text/plain, Size: 1099 bytes --]

2.6.31-stable review patch. If anyone has any objections, please let us know.

------------------
From: Kusanagi Kouichi <slash@ma.neweb.ne.jp>

[ Upstream commit 36989b90879c785f95b877bdcf65a2527dadd893 ]

After commit 2b980dbd77d229eb60588802162c9659726b11f4
("lsm: Add hooks to the TUN driver") tun_set_iff doesn't
return -EINVAL though neither IFF_TUN nor IFF_TAP is set.

Signed-off-by: Kusanagi Kouichi <slash@ma.neweb.ne.jp>
Reviewed-by: Paul Moore <paul.moore@hp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/net/tun.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -943,8 +943,6 @@ static int tun_set_iff(struct net *net,
char *name;
unsigned long flags = 0;

- err = -EINVAL;
-
if (!capable(CAP_NET_ADMIN))
return -EPERM;

@@ -958,7 +956,7 @@ static int tun_set_iff(struct net *net,
flags |= TUN_TAP_DEV;
name = "tap%d";
} else
- goto failed;
+ return -EINVAL;

if (*ifr->ifr_name)
name = ifr->ifr_name;