Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: keith.busch@linux.intel.com (Keith Busch)
Subject: [PATCH v2 2/2] nvme-pci: release nvme_ctrl if failed to alloc memory in nvme_probe
Date: Tue, 10 Jul 2018 08:45:52 -0600	[thread overview]
Message-ID: <20180710144552.GC11548@localhost.localdomain> (raw)
In-Reply-To: <4f4b62ad826bc11debfab9eff3d460b03ec66f08.1530548893.git.zhangweiping@didichuxing.com>

On Tue, Jul 03, 2018@12:35:44AM +0800, Weiping Zhang wrote:
> release nvme_ctrl if failed to alloc memory for iod_mempool, otherwise
> /dev/nvmeX cann't be removed for this nvme controller, any ioctl to
> this device doesn't work.
> 
> Signed-off-by: Weiping Zhang <zhangweiping at didichuxing.com>
> ---
>  drivers/nvme/host/pci.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> index 92a8b5b2b39e..29aff33c4b4c 100644
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c
> @@ -2576,8 +2576,10 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>  						(void *) alloc_size,
>  						GFP_KERNEL, node);
>  	if (!dev->iod_mempool) {
> -		result = -ENOMEM;
> -		goto release_pools;
> +		nvme_uninit_ctrl(&dev->ctrl);
> +		/* all above resource will be released after put ctrl */
> +		nvme_put_ctrl(&dev->ctrl);
> +		return -ENOMEM;
>  	}
>  
>  	dev_info(dev->ctrl.device, "pci function %s\n", dev_name(&pdev->dev));
> -- 

I think it would be better to just move the mempool allocation above
nvme_init_ctrl.

  reply	other threads:[~2018-07-10 14:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-02 16:35 [PATCH v2 0/2] release /dev/nvmeX if nvme_probe failed Weiping Zhang
2018-07-02 16:35 ` [PATCH v2 1/2] nvme-pci: release iomap and prp_pools in nvme_pci_free_ctrl Weiping Zhang
2018-07-10 14:45   ` Keith Busch
2018-07-11 13:38     ` Weiping Zhang
2018-07-11 15:03       ` Keith Busch
2018-07-11 15:38         ` Weiping Zhang
2018-07-11 16:04           ` Keith Busch
2018-07-02 16:35 ` [PATCH v2 2/2] nvme-pci: release nvme_ctrl if failed to alloc memory in nvme_probe Weiping Zhang
2018-07-10 14:45   ` Keith Busch [this message]
2018-07-10 11:32 ` [PATCH v2 0/2] release /dev/nvmeX if nvme_probe failed Christoph Hellwig
2018-07-10 14:09   ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180710144552.GC11548@localhost.localdomain \
    --to=keith.busch@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox