Skip to content

Commit bcb3b90

Browse files
gomesjgregkh
authored andcommitted
tun: allow positive return values on dev_get_valid_name() call
[ Upstream commit 5c25f65fd1e42685f7ccd80e0621829c105785d9 ] 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 5c8a085 commit bcb3b90

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
@@ -1685,7 +1685,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
16851685
if (!dev)
16861686
return -ENOMEM;
16871687
err = dev_get_valid_name(net, dev, name);
1688-
if (err)
1688+
if (err < 0)
16891689
goto err_free_dev;
16901690

16911691
dev_net_set(dev, net);

0 commit comments

Comments
 (0)