From b6151ce997af650c58c1d00ecc95c903e9e00c63 Mon Sep 17 00:00:00 2001 From: Dmitriy Linikov Date: Tue, 14 Aug 2018 07:13:41 -0600 Subject: [PATCH] drivers/net/tun.c: Fixed custom tun devname formatting. --- drivers/net/tun.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index d7b0cec6007..0a678f53464 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1231,6 +1231,13 @@ static int tun_dev_init(FAR struct tun_device_s *priv, FAR struct file *filep, tun_ifdown(&priv->dev); + /* Assign d_ifname if specified. */ + + if (devfmt) + { + strncpy(priv->dev.d_ifname, devfmt, IFNAMSIZ); + } + /* Register the device with the OS so that socket IOCTLs can be performed */ ret = netdev_register(&priv->dev, NET_LL_TUN); @@ -1242,13 +1249,6 @@ static int tun_dev_init(FAR struct tun_device_s *priv, FAR struct file *filep, return ret; } - /* Assign d_ifname if specified. This must be done after registration */ - - if (devfmt) - { - strncpy(priv->dev.d_ifname, devfmt, IFNAMSIZ); - } - priv->filep = filep; /* Set link to file */ filep->f_priv = priv; /* Set link to TUN device */