Skip to content

Commit 80f513b

Browse files
author
Keith Busch
committed
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 <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 3831761 commit 80f513b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/nvme/host/pci.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2492,8 +2492,10 @@ static unsigned long check_vendor_combination_bug(struct pci_dev *pdev)
24922492
static void nvme_async_probe(void *data, async_cookie_t cookie)
24932493
{
24942494
struct nvme_dev *dev = data;
2495+
24952496
nvme_reset_ctrl_sync(&dev->ctrl);
24962497
flush_work(&dev->ctrl.scan_work);
2498+
nvme_put_ctrl(&dev->ctrl);
24972499
}
24982500

24992501
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)
25402542

25412543
dev_info(dev->ctrl.device, "pci function %s\n", dev_name(&pdev->dev));
25422544

2545+
nvme_get_ctrl(&dev->ctrl);
25432546
async_schedule(nvme_async_probe, dev);
25442547

25452548
return 0;

0 commit comments

Comments
 (0)