* [PATCH V2] nvme-pci: avoid dereference of symbol from unloaded module
@ 2017-11-09 11:32 Ming Lei
2017-11-09 11:38 ` Sagi Grimberg
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Ming Lei @ 2017-11-09 11:32 UTC (permalink / raw)
The 'remove_work' may be scheduled to run after nvme_remove()
returns since we can't simply cancel it in nvme_remove() for
avoiding deadlock. Once nvme_remove() returns, this module(nvme)
can be unloaded.
On the other hand, nvme_put_ctrl() calls ctr->ops->free_ctrl
which may point to nvme_pci_free_ctrl() in unloaded module.
This patch avoids this issue by queuing 'remove_work' via 'nvme_wq',
and flush this worqueue in nvme_exit() as suggested by Sagi.
Suggested-by: Sagi Grimberg <sagi at grimberg.me>
Signed-off-by: Ming Lei <ming.lei at redhat.com>
---
drivers/nvme/host/pci.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 32c413ec818c..be2ea99684ff 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2290,7 +2290,7 @@ static void nvme_remove_dead_ctrl(struct nvme_dev *dev, int status)
nvme_get_ctrl(&dev->ctrl);
nvme_dev_disable(dev, false);
- if (!schedule_work(&dev->remove_work))
+ if (!queue_work(nvme_wq, &dev->remove_work))
nvme_put_ctrl(&dev->ctrl);
}
@@ -2713,6 +2713,7 @@ static int __init nvme_init(void)
static void __exit nvme_exit(void)
{
pci_unregister_driver(&nvme_driver);
+ flush_workqueue(nvme_wq);
_nvme_check_size();
}
--
2.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH V2] nvme-pci: avoid dereference of symbol from unloaded module
2017-11-09 11:32 [PATCH V2] nvme-pci: avoid dereference of symbol from unloaded module Ming Lei
@ 2017-11-09 11:38 ` Sagi Grimberg
2017-11-09 16:48 ` Keith Busch
2017-11-09 18:31 ` Christoph Hellwig
2 siblings, 0 replies; 4+ messages in thread
From: Sagi Grimberg @ 2017-11-09 11:38 UTC (permalink / raw)
Thanks Ming,
Reviewed-by: Sagi Grimberg <sagi at grimberg.me>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH V2] nvme-pci: avoid dereference of symbol from unloaded module
2017-11-09 11:32 [PATCH V2] nvme-pci: avoid dereference of symbol from unloaded module Ming Lei
2017-11-09 11:38 ` Sagi Grimberg
@ 2017-11-09 16:48 ` Keith Busch
2017-11-09 18:31 ` Christoph Hellwig
2 siblings, 0 replies; 4+ messages in thread
From: Keith Busch @ 2017-11-09 16:48 UTC (permalink / raw)
Looks good, thanks.
Reviewed-by: Keith Busch <keith.busch at intel.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH V2] nvme-pci: avoid dereference of symbol from unloaded module
2017-11-09 11:32 [PATCH V2] nvme-pci: avoid dereference of symbol from unloaded module Ming Lei
2017-11-09 11:38 ` Sagi Grimberg
2017-11-09 16:48 ` Keith Busch
@ 2017-11-09 18:31 ` Christoph Hellwig
2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2017-11-09 18:31 UTC (permalink / raw)
Thanks,
applied to nvme-4.15.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-11-09 18:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-09 11:32 [PATCH V2] nvme-pci: avoid dereference of symbol from unloaded module Ming Lei
2017-11-09 11:38 ` Sagi Grimberg
2017-11-09 16:48 ` Keith Busch
2017-11-09 18:31 ` Christoph Hellwig
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.