diff options
author | 2017-07-19 11:53:16 -0700 | |
---|---|---|
committer | 2017-07-19 22:20:05 -0700 | |
commit | 9749fed5d43d84b86f1c98b70167c31c296bb6a6 (patch) | |
tree | 0ec6e775b34202d7725fc768cd0742f3ae6ebfcc /drivers/net/hyperv/netvsc.c | |
parent | netvsc: change logic for change mtu and set_queues (diff) | |
download | linux-9749fed5d43d84b86f1c98b70167c31c296bb6a6.tar.gz linux-9749fed5d43d84b86f1c98b70167c31c296bb6a6.tar.bz2 linux-9749fed5d43d84b86f1c98b70167c31c296bb6a6.zip |
netvsc: use ERR_PTR to avoid dereference issues
The rndis_filter_device_add function is called both in
probe context and RTNL context,and creates the netvsc_device
inner structure. It is easier to get the RTNL lock annotation
correct if it returns the object directly, rather than implicitly
by updating network device private data.
Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/hyperv/netvsc.c')
-rw-r--r-- | drivers/net/hyperv/netvsc.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index e202ec5d6f63..4a2550559442 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -29,6 +29,8 @@ #include <linux/netdevice.h> #include <linux/if_ether.h> #include <linux/vmalloc.h> +#include <linux/rtnetlink.h> + #include <asm/sync_bitops.h> #include "hyperv_net.h" @@ -1272,8 +1274,8 @@ void netvsc_channel_cb(void *context) * netvsc_device_add - Callback when the device belonging to this * driver is added */ -int netvsc_device_add(struct hv_device *device, - const struct netvsc_device_info *device_info) +struct netvsc_device *netvsc_device_add(struct hv_device *device, + const struct netvsc_device_info *device_info) { int i, ret = 0; int ring_size = device_info->ring_size; @@ -1283,7 +1285,7 @@ int netvsc_device_add(struct hv_device *device, net_device = alloc_net_device(); if (!net_device) - return -ENOMEM; + return ERR_PTR(-ENOMEM); net_device->ring_size = ring_size; @@ -1339,7 +1341,7 @@ int netvsc_device_add(struct hv_device *device, goto close; } - return ret; + return net_device; close: netif_napi_del(&net_device->chan_table[0].napi); @@ -1350,6 +1352,5 @@ close: cleanup: free_netvsc_device(&net_device->rcu); - return ret; - + return ERR_PTR(ret); } |