From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH] kni: unregister an unregisterd net_device could cause a kernel crash Date: Thu, 8 Sep 2016 09:47:35 -0700 Message-ID: <20160908094735.5861477b@xeon-e3> References: <1473388936-2706-1-git-send-email-zhouyates@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: ferruh.yigit@intel.com, dev@dpdk.org To: zhouyangchao Return-path: Received: from mail-pa0-f47.google.com (mail-pa0-f47.google.com [209.85.220.47]) by dpdk.org (Postfix) with ESMTP id 4A7E2558B for ; Thu, 8 Sep 2016 18:47:26 +0200 (CEST) Received: by mail-pa0-f47.google.com with SMTP id id6so19001650pad.3 for ; Thu, 08 Sep 2016 09:47:26 -0700 (PDT) In-Reply-To: <1473388936-2706-1-git-send-email-zhouyates@gmail.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Fri, 9 Sep 2016 10:42:16 +0800 zhouyangchao wrote: > Signed-off-by: zhouyangchao > --- > lib/librte_eal/linuxapp/kni/kni_misc.c | 3 +++ > 1 files changed, 3 insertions(+), 0 deletions(-) > > diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c > index 67e9b7d..17b6d7a 100644 > --- a/lib/librte_eal/linuxapp/kni/kni_misc.c > +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c > @@ -361,6 +361,9 @@ kni_dev_remove(struct kni_dev *dev) > igb_kni_remove(dev->pci_dev); > > if (dev->net_dev) { > + if (dev->net_dev->state == NETREG_REGISTERED) { > + unregister_netdev(dev->net_dev); > + } > unregister_netdev(dev->net_dev); > free_netdev(dev->net_dev); > } The real problem is kni_dev_remove should not be called when register_netdevice fails. Why not just fix that unwind path.