All of lore.kernel.org
 help / color / mirror / Atom feed
From: hch@lst.de (Christoph Hellwig)
Subject: [PATCH] nvme: pci: Fix NULL dereference when resetting NVMe SSD
Date: Mon, 22 May 2017 18:02:17 +0200	[thread overview]
Message-ID: <20170522160217.GA26104@lst.de> (raw)
In-Reply-To: <20170522153829.GA17980@dhcp-216.srv.tuxera.com>

On Mon, May 22, 2017@06:38:29PM +0300, Rakesh Pandit wrote:
> Just got to use the using the test box again and you are right that
> nvme_remove_dead_ctrl_work is getting called just before the NULL
> pointer dereference.
> 
> Here call trace to nvme_timeout which results in eventually call to
> nvme_reset when it wants to reset the controller (which races with
> ->reset_notify from PCI layer):

Does the patch below fix the issue for you?

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index b01bd5bba8e6..f8c15e2719c4 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4275,11 +4275,13 @@ int pci_reset_function(struct pci_dev *dev)
 	if (rc)
 		return rc;
 
+	device_lock(&dev->dev);
 	pci_dev_save_and_disable(dev);
 
-	rc = pci_dev_reset(dev, 0);
+	rc = __pci_dev_reset(dev, 0);
 
 	pci_dev_restore(dev);
+	device_unlock(&dev->dev);
 
 	return rc;
 }

WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Rakesh Pandit <rakesh@tuxera.com>
Cc: Christoph Hellwig <hch@lst.de>,
	linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
	Keith Busch <keith.busch@intel.com>, Jens Axboe <axboe@fb.com>,
	Sagi Grimberg <sagi@grimberg.me>,
	linux-pci@vger.kernel.org
Subject: Re: [PATCH] nvme: pci: Fix NULL dereference when resetting NVMe SSD
Date: Mon, 22 May 2017 18:02:17 +0200	[thread overview]
Message-ID: <20170522160217.GA26104@lst.de> (raw)
In-Reply-To: <20170522153829.GA17980@dhcp-216.srv.tuxera.com>

On Mon, May 22, 2017 at 06:38:29PM +0300, Rakesh Pandit wrote:
> Just got to use the using the test box again and you are right that
> nvme_remove_dead_ctrl_work is getting called just before the NULL
> pointer dereference.
> 
> Here call trace to nvme_timeout which results in eventually call to
> nvme_reset when it wants to reset the controller (which races with
> ->reset_notify from PCI layer):

Does the patch below fix the issue for you?

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index b01bd5bba8e6..f8c15e2719c4 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4275,11 +4275,13 @@ int pci_reset_function(struct pci_dev *dev)
 	if (rc)
 		return rc;
 
+	device_lock(&dev->dev);
 	pci_dev_save_and_disable(dev);
 
-	rc = pci_dev_reset(dev, 0);
+	rc = __pci_dev_reset(dev, 0);
 
 	pci_dev_restore(dev);
+	device_unlock(&dev->dev);
 
 	return rc;
 }

  reply	other threads:[~2017-05-22 16:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-20 17:59 [PATCH] nvme: pci: Fix NULL dereference when resetting NVMe SSD Rakesh Pandit
2017-05-20 17:59 ` Rakesh Pandit
2017-05-21  6:17 ` Christoph Hellwig
2017-05-21  6:17   ` Christoph Hellwig
2017-05-22 15:38   ` Rakesh Pandit
2017-05-22 15:38     ` Rakesh Pandit
2017-05-22 16:02     ` Christoph Hellwig [this message]
2017-05-22 16:02       ` Christoph Hellwig
2017-05-22 16:04       ` Christoph Hellwig
2017-05-22 16:04         ` Christoph Hellwig
2017-05-22 20:15         ` Rakesh Pandit
2017-05-22 20:15           ` Rakesh Pandit

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=20170522160217.GA26104@lst.de \
    --to=hch@lst.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.