Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp820361imm; Fri, 29 Jun 2018 06:59:44 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc+Zn/wUwNV/U3CLsVP6yXtn6HUzQ1k348opfB6zYIrx1W05P2RP9AKSqGuYxUp0piceSpy X-Received: by 2002:a62:ba13:: with SMTP id k19-v6mr14636995pff.245.1530280784596; Fri, 29 Jun 2018 06:59:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530280784; cv=none; d=google.com; s=arc-20160816; b=gnWNVKKeE+YzFoPfu4SsYfnG8XKE8wWyPnVBtKBAiFHPfZTV3SMuJxeQBYXFKkPDja GuwNu250amM86H6fFaWHNaqMMcUbIYBqw4SczzsyjlZtwWPp9p+KLALqytNHIWZnNIj0 9LwfIVkagIp2sH2GsaT+HpL6nBQt90My1k4bP9PLcnIyBQDbr3LRbwUOIVA3jVVCLqV8 CZzYKyXg/u4k3UJZhlUPRSj7MvX3kE+flK55OyzS/OUDLZtuFKkOOB2W32ilWWBb/7EE Gfv23MFbx4rlS4VTyT3Cs4+XY+U09RlQ/wxzl/qS/XWlW1JtKWMtgu0CIalMmSp8JlEV MthA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=KsirV9HR4QSJViahnjR8nHkm9XcUHQgvQfsNZVas0so=; b=LPo/SMxGlgPo1fHm5qPmbpmQh3joYjUNLwsWXoejWe3FCBKxdCDbEf5kGwQdTkKQrC 6Twn0g5TCl+L2S0znzmz0NGRI/RXuarsvbmOrSCOGFPKGcE0t5yyMsiiGlUbMd5Dd0hJ Md8I6h8QX88RNbB7xwaKfqbNsgvWBZrypBG7f5IO+89xg1AakxNom/AFJMauDdAZK0jX gwr72nvXThBYa2J9tjjUD+9TkJWurKqspoG6X7I+bhirAOgHeYzzXNUAs6kc5KUnJ5vz VGnKcV2ruRiFClBtWRimEDZlkRh8QcbaLkxh4iIjBu9elT40S5miISCi5lom1oWOjDvl 8Fig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t1-v6si8381786pgn.42.2018.06.29.06.59.30; Fri, 29 Jun 2018 06:59:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936045AbeF2Lei (ORCPT + 99 others); Fri, 29 Jun 2018 07:34:38 -0400 Received: from charlotte.tuxdriver.com ([70.61.120.58]:51066 "EHLO smtp.tuxdriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934003AbeF2Leg (ORCPT ); Fri, 29 Jun 2018 07:34:36 -0400 Received: from cpe-2606-a000-111b-40b7-640c-26a-4e16-9225.dyn6.twc.com ([2606:a000:111b:40b7:640c:26a:4e16:9225] helo=localhost) by smtp.tuxdriver.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1fYrfY-0005kf-8I; Fri, 29 Jun 2018 07:34:33 -0400 Date: Fri, 29 Jun 2018 07:33:55 -0400 From: Neil Horman To: Adit Ranadive Cc: Jason Gunthorpe , "linux-rdma@vger.kernel.org" , pv-drivers , Doug Ledford , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] vmw_pvrdma: Release netdev when vmxnet3 module is removed Message-ID: <20180629113355.GB16153@hmswarspite.think-freely.org> References: <20180628135938.19625-1-nhorman@tuxdriver.com> <20180628185946.GC379@ziepe.ca> <20180628194526.GA14168@hmswarspite.think-freely.org> <20180628203709.GD379@ziepe.ca> <74E5B871-3D33-4C75-8FD4-C5D5BE2182AD@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <74E5B871-3D33-4C75-8FD4-C5D5BE2182AD@vmware.com> User-Agent: Mutt/1.10.0 (2018-05-17) X-Spam-Score: -2.9 (--) X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 28, 2018 at 09:15:46PM +0000, Adit Ranadive wrote: > On 6/28/18, 1:37 PM, "Jason Gunthorpe" wrote: > > On Thu, Jun 28, 2018 at 03:45:26PM -0400, Neil Horman wrote: > > > On Thu, Jun 28, 2018 at 12:59:46PM -0600, Jason Gunthorpe wrote: > > > > On Thu, Jun 28, 2018 at 09:59:38AM -0400, Neil Horman wrote: > > > > > On repeated module load/unload cycles, its possible for the pvrmda > > > > > driver to encounter this crash: > > > > > > @@ -962,6 +982,7 @@ static int pvrdma_pci_probe(struct pci_dev *pdev, > > > > > } > > > > > > > > > > dev->netdev = pci_get_drvdata(pdev_net); > > > > > + dev_hold(dev->netdev); > > That doesn't seem right. If the vmxnet3 driver isn't loaded at all or failed > to create a netdev, you would be requesting a hold on a NULL netdev. What if > you moved this to after the if(!dev->netdev) check? > You're correct, I was thinking that there was a null check in dev_hold, but there isn't, it needs to be moved after the the !dev->netdev, and released in the error path. > > > > > pci_dev_put(pdev_net); > > > > > if (!dev->netdev) { > > > > > dev_err(&pdev->dev, "failed to get vmxnet3 device\n"); > > > > > > > > I see a lot of new dev_hold's here, where are the matching > > > > dev_puts()? > > > > > > I'm not sure I'd call 2 alot, but sure, there is a new dev_hold in the > > pvrdma_pci_probe routine, to hold a reference to the netdev that is looked up > > there. It is balanced by the NETDEV_UNREGISTER case in > > pvrdma_netdevice_event_handle. The UNREGISTER clause is also balancing the > > NETDEV_REGISTER case of the hanlder that looks up the matching netdev should a > > new device be registered. Note that we will only hold a single device at a > > time, because a given pvrdma device only recongnizes a single vmxnet3 device > > (the one on function 0 of its own bus/device tuple). > > > > I don't see how the dev_hold in pvrdma_pci_probe is undone during > > error unwind (eg goto err_free_cq_ring) > > > > And I don't see how it is put when pvrdma_pci_remove() is called. > > That's right. These seem missing as well. > yup