netvsc: fix error unwind on device setup failure
authorstephen hemminger <stephen@networkplumber.org>
Fri, 28 Jul 2017 15:59:46 +0000 (08:59 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sat, 29 Jul 2017 22:25:43 +0000 (15:25 -0700)
If setting receive buffer fails, the error unwind would cause
kernel panic because it was not correctly doing RCU and NAPI
unwind.  RCU'd pointer needs to be reset to NULL, and NAPI needs
to be disabled not deleted.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/hyperv/netvsc.c

index 4c709b454d3481a28e0d9cf80f5e88ec46d02f6b..db95487807fda0138775db93b065370bef1ea9a5 100644 (file)
@@ -1307,7 +1307,8 @@ struct netvsc_device *netvsc_device_add(struct hv_device *device,
        return net_device;
 
 close:
-       netif_napi_del(&net_device->chan_table[0].napi);
+       RCU_INIT_POINTER(net_device_ctx->nvdev, NULL);
+       napi_disable(&net_device->chan_table[0].napi);
 
        /* Now, we can close the channel safely */
        vmbus_close(device->channel);