Skip to content

Commit 210a641

Browse files
gomesjgregkh
authored andcommitted
tun: allow positive return values on dev_get_valid_name() call
[ Upstream commit 5c25f65 ] 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 <julien@arista.com> Acked-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d6b1aeb commit 210a641

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/net/tun.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1788,7 +1788,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
17881788
if (!dev)
17891789
return -ENOMEM;
17901790
err = dev_get_valid_name(net, dev, name);
1791-
if (err)
1791+
if (err < 0)
17921792
goto err_free_dev;
17931793

17941794
dev_net_set(dev, net);

0 commit comments

Comments
 (0)