From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: [PATCH net-stable 16/24] hv_netvsc: disable NAPI before channel close Date: Mon, 14 May 2018 15:32:15 -0700 Message-ID: <20180514223223.25433-17-sthemmin@microsoft.com> References: <20180514223223.25433-1-sthemmin@microsoft.com> Cc: netdev@vger.kernel.org, Stephen Hemminger , Stephen Hemminger To: davem@davemloft.net Return-path: Received: from mail-pl0-f67.google.com ([209.85.160.67]:34329 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752293AbeENWcy (ORCPT ); Mon, 14 May 2018 18:32:54 -0400 Received: by mail-pl0-f67.google.com with SMTP id ay10-v6so8176653plb.1 for ; Mon, 14 May 2018 15:32:53 -0700 (PDT) In-Reply-To: <20180514223223.25433-1-sthemmin@microsoft.com> Sender: netdev-owner@vger.kernel.org List-ID: From: Stephen Hemminger commit 8348e0460ab1473f06c8b824699dd2eed3c1979d upstream This makes sure that no CPU is still process packets when the channel is closed. Fixes: 76bb5db5c749 ("netvsc: fix use after free on module removal") Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- drivers/net/hyperv/netvsc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index 7e0eb99571af..a8789dc4fc9b 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -567,6 +567,10 @@ void netvsc_device_remove(struct hv_device *device) RCU_INIT_POINTER(net_device_ctx->nvdev, NULL); + /* And disassociate NAPI context from device */ + for (i = 0; i < net_device->num_chn; i++) + netif_napi_del(&net_device->chan_table[i].napi); + /* * At this point, no one should be accessing net_device * except in here @@ -578,10 +582,6 @@ void netvsc_device_remove(struct hv_device *device) netvsc_teardown_gpadl(device, net_device); - /* And dissassociate NAPI context from device */ - for (i = 0; i < net_device->num_chn; i++) - netif_napi_del(&net_device->chan_table[i].napi); - /* Release all resources */ free_netvsc_device_rcu(net_device); } -- 2.17.0