summaryrefslogtreecommitdiffstats
path: root/drivers/nvme/host/pci.c
diff options
context:
space:
mode:
authorKeith Busch2018-05-07 16:30:24 +0200
committerKeith Busch2018-05-07 16:30:24 +0200
commit80f513b5056d0bf127653d2327b7b24e322dc7e3 (patch)
treef1e68c4104d1e77433a3a596b431ea9efdd4effe /drivers/nvme/host/pci.c
parentnvme: only reconfigure discard if necessary (diff)
downloadkernel-qcow2-linux-80f513b5056d0bf127653d2327b7b24e322dc7e3.tar.gz
kernel-qcow2-linux-80f513b5056d0bf127653d2327b7b24e322dc7e3.tar.xz
kernel-qcow2-linux-80f513b5056d0bf127653d2327b7b24e322dc7e3.zip
nvme/pci: Hold controller reference during async probe
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@redhat.com> Signed-off-by: Keith Busch <keith.busch@intel.com>
Diffstat (limited to 'drivers/nvme/host/pci.c')
-rw-r--r--drivers/nvme/host/pci.c3
1 files changed, 3 insertions, 0 deletions
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;