nvme-pci: Fix async probe remove race
PATCH 1/1 nvme-pci: Fix async probe remove race
From: Keith Busch <[email protected]>
Ensure the controller is not in the NEW state when nvme_probe() exits. This will always allow a subsequent nvme_remove() to set the state to DELETING, fixing a potential race between the initial asynchronous probe and device removal.
Reported-by Li Zhong <lizhongfs at gmail.com>
Cc Sagi Grimberg <sagi at grimberg.me>
Signed-off-by Keith Busch <kbusch at kernel.org>
--- drivers/nvme/host/pci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/host/pci.c +2 -1
@@ -2695,7 +2695,7 @@ 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.reset_work);flush_work (&dev->ctrl.scan_work);nvme_put_ctrl (&dev->ctrl); }
@@ -2761,6 +2761,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_reset_ctrl (&dev->ctrl);nvme_get_ctrl (&dev->ctrl);async_schedule (nvme_async_probe, dev);
Signature · 1 line
2.14.4
Sagi Grimberg
maintainerPATCH 1/1 nvme-pci: Fix async probe remove race
Reviewed-by Sagi Grimberg <sagi at grimberg.me>
PATCH 1/1 nvme-pci: Fix async probe remove race
In reply to Keith Buschapplied to nvme-5.3-rc