Otherwise, register_netdevice advertises the creation of the device with
the default flags, instead of what the user requested.
Reported-by: Thomas Haller <thaller@redhat.com>
Fixes: 1ec010e70593 ("tun: export flags, uid, gid, queue information over netlink")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
                         */
                        return 0;
                }
+
+               tun->flags = (tun->flags & ~TUN_FEATURES) |
+                             (ifr->ifr_flags & TUN_FEATURES);
        }
        else {
                char *name;
                                     ~(NETIF_F_HW_VLAN_CTAG_TX |
                                       NETIF_F_HW_VLAN_STAG_TX);
 
+               tun->flags = (tun->flags & ~TUN_FEATURES) |
+                             (ifr->ifr_flags & TUN_FEATURES);
+
                INIT_LIST_HEAD(&tun->disabled);
                err = tun_attach(tun, file, false, ifr->ifr_flags & IFF_NAPI);
                if (err < 0)
 
        tun_debug(KERN_INFO, tun, "tun_set_iff\n");
 
-       tun->flags = (tun->flags & ~TUN_FEATURES) |
-               (ifr->ifr_flags & TUN_FEATURES);
-
        /* Make sure persistent devices do not get stuck in
         * xoff state.
         */