Skip to content

Commit 5c25f65

Browse files
gomesjdavem330
authored andcommitted
tun: allow positive return values on dev_get_valid_name() call
If the name argument of dev_get_valid_name() contains "%d", it will try to assign it a unit number in __dev__alloc_name() and return either the unit number (>= 0) or an error code (< 0). Considering positive values as error values prevent tun device creations relying this mechanism, therefor we should only consider negative values as errors here. Signed-off-by: Julien Gomes <[email protected]> Acked-by: Cong Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d309ae5 commit 5c25f65

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/net/tun.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2028,7 +2028,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
20282028
if (!dev)
20292029
return -ENOMEM;
20302030
err = dev_get_valid_name(net, dev, name);
2031-
if (err)
2031+
if (err < 0)
20322032
goto err_free_dev;
20332033

20342034
dev_net_set(dev, net);

0 commit comments

Comments
 (0)