Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751484AbdGQQDF (ORCPT ); Mon, 17 Jul 2017 12:03:05 -0400 Received: from mga02.intel.com ([134.134.136.20]:55797 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751346AbdGQQDD (ORCPT ); Mon, 17 Jul 2017 12:03:03 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,375,1496127600"; d="scan'208";a="287884209" Date: Mon, 17 Jul 2017 12:09:18 -0400 From: Keith Busch To: Christophe JAILLET Cc: axboe@fb.com, hch@lst.de, sagi@grimberg.me, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] nvme-pci: Fix an error handling path in 'nvme_probe()' Message-ID: <20170717160918.GD24365@localhost.localdomain> References: <20170716083903.7108-1-christophe.jaillet@wanadoo.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170716083903.7108-1-christophe.jaillet@wanadoo.fr> User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1561 Lines: 47 On Sun, Jul 16, 2017 at 10:39:03AM +0200, Christophe JAILLET wrote: > Release resources in the correct order in order not to miss a > 'put_device()' if 'nvme_dev_map()' fails. > > Fixes: b00a726a9fd8 ("NVMe: Don't unmap controller registers on reset") > Signed-off-by: Christophe JAILLET Indeed, thanks for the fix. Alternatively this can be fixed by relocating nvme_dev_map prior to the 'get_device' a few lines up. This patch is okay, too. Reviewed-by: Keith Busch > diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c > index d10d2f279d19..005beffd005d 100644 > --- a/drivers/nvme/host/pci.c > +++ b/drivers/nvme/host/pci.c > @@ -2282,7 +2282,7 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id) > > result = nvme_dev_map(dev); > if (result) > - goto free; > + goto put_pci; > > INIT_WORK(&dev->ctrl.reset_work, nvme_reset_work); > INIT_WORK(&dev->remove_work, nvme_remove_dead_ctrl_work); > @@ -2291,7 +2291,7 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id) > > result = nvme_setup_prp_pools(dev); > if (result) > - goto put_pci; > + goto unmap; > > quirks |= check_dell_samsung_bug(pdev); > > @@ -2308,9 +2308,10 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id) > > release_pools: > nvme_release_prp_pools(dev); > + unmap: > + nvme_dev_unmap(dev); > put_pci: > put_device(dev->dev); > - nvme_dev_unmap(dev); > free: > kfree(dev->queues); > kfree(dev);