linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH nvme-4.18] nvme/pci: Hold controller reference during async probe
@ 2018-05-07 16:43 Keith Busch
  2018-05-09  5:12 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Keith Busch @ 2018-05-07 16:43 UTC (permalink / raw)


It is possible the driver's remove may have freed the controller if
the remove callback is invoked prior to the async_schedule starting
the reset_work. This patch fixes that by holding a reference on the
controller.

Reported-by: Mikulas Patocka <mpatocka at redhat.com>
Signed-off-by: Keith Busch <keith.busch at intel.com>
---
 drivers/nvme/host/pci.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index dcd1be005eef..7acecdf25621 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2492,8 +2492,10 @@ static unsigned long check_vendor_combination_bug(struct pci_dev *pdev)
 static void nvme_async_probe(void *data, async_cookie_t cookie)
 {
 	struct nvme_dev *dev = data;
+
 	nvme_reset_ctrl_sync(&dev->ctrl);
 	flush_work(&dev->ctrl.scan_work);
+	nvme_put_ctrl(&dev->ctrl);
 }
 
 static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
@@ -2540,6 +2542,7 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	dev_info(dev->ctrl.device, "pci function %s\n", dev_name(&pdev->dev));
 
+	nvme_get_ctrl(&dev->ctrl);
 	async_schedule(nvme_async_probe, dev);
 
 	return 0;
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH nvme-4.18] nvme/pci: Hold controller reference during async probe
  2018-05-07 16:43 [PATCH nvme-4.18] nvme/pci: Hold controller reference during async probe Keith Busch
@ 2018-05-09  5:12 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2018-05-09  5:12 UTC (permalink / raw)


On Mon, May 07, 2018@10:43:22AM -0600, Keith Busch wrote:
> It is possible the driver's remove may have freed the controller if
> the remove callback is invoked prior to the async_schedule starting
> the reset_work. This patch fixes that by holding a reference on the
> controller.
> 
> Reported-by: Mikulas Patocka <mpatocka at redhat.com>
> Signed-off-by: Keith Busch <keith.busch at intel.com>

Looks fine,

Reviewed-by: Christoph Hellwig <hch at lst.de>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-05-09  5:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-07 16:43 [PATCH nvme-4.18] nvme/pci: Hold controller reference during async probe Keith Busch
2018-05-09  5:12 ` Christoph Hellwig

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).