diff options
author | Cong Wang <xiyou.wangcong@gmail.com> | 2017-10-13 11:58:53 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-10-16 21:02:54 +0100 |
commit | 0ad646c81b2182f7fa67ec0c8c825e0ee165696d (patch) | |
tree | 82aef9de787aa5f334a4802314385d8e8e443138 /net/core | |
parent | 2459b4c635858094df78abb9ca87d99f89fe8ca5 (diff) | |
download | linux-0ad646c81b2182f7fa67ec0c8c825e0ee165696d.tar.gz linux-0ad646c81b2182f7fa67ec0c8c825e0ee165696d.tar.bz2 linux-0ad646c81b2182f7fa67ec0c8c825e0ee165696d.zip |
tun: call dev_get_valid_name() before register_netdevice()
register_netdevice() could fail early when we have an invalid
dev name, in which case ->ndo_uninit() is not called. For tun
device, this is a problem because a timer etc. are already
initialized and it expects ->ndo_uninit() to clean them up.
We could move these initializations into a ->ndo_init() so
that register_netdevice() knows better, however this is still
complicated due to the logic in tun_detach().
Therefore, I choose to just call dev_get_valid_name() before
register_netdevice(), which is quicker and much easier to audit.
And for this specific case, it is already enough.
Fixes: 96442e42429e ("tuntap: choose the txq based on rxq")
Reported-by: Dmitry Alexeev <avekceeb@gmail.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/dev.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 588b473194a8..11596a302a26 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -1147,9 +1147,8 @@ static int dev_alloc_name_ns(struct net *net, return ret; } -static int dev_get_valid_name(struct net *net, - struct net_device *dev, - const char *name) +int dev_get_valid_name(struct net *net, struct net_device *dev, + const char *name) { BUG_ON(!net); @@ -1165,6 +1164,7 @@ static int dev_get_valid_name(struct net *net, return 0; } +EXPORT_SYMBOL(dev_get_valid_name); /** * dev_change_name - change name of a device |