linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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:04:20 +0200	[thread overview]
Message-ID: <20170522160420.GA26356@lst.de> (raw)
In-Reply-To: <20170522160217.GA26104@lst.de>

On Mon, May 22, 2017 at 06:02:17PM +0200, Christoph Hellwig wrote:
> 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?

Actually, it probably should be this one, but for you the effects
are probably the same:

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index b01bd5bba8e6..b61ad77dc322 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;
 
+	pci_dev_lock(dev);
 	pci_dev_save_and_disable(dev);
 
-	rc = pci_dev_reset(dev, 0);
+	rc = __pci_dev_reset(dev, 0);
 
 	pci_dev_restore(dev);
+	pci_dev_unlock(dev);
 
 	return rc;
 }

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

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20170520175952.GA11258@dhcp-216.srv.tuxera.com>
2017-05-21  6:17 ` [PATCH] nvme: pci: Fix NULL dereference when resetting NVMe SSD Christoph Hellwig
2017-05-22 15:38   ` Rakesh Pandit
2017-05-22 16:02     ` Christoph Hellwig
2017-05-22 16:04       ` Christoph Hellwig [this message]
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=20170522160420.GA26356@lst.de \
    --to=hch@lst.de \
    --cc=axboe@fb.com \
    --cc=keith.busch@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=rakesh@tuxera.com \
    --cc=sagi@grimberg.me \
    /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;
as well as URLs for NNTP newsgroup(s).