Commit 3a6b0761 authored by Christoph Hellwig's avatar Christoph Hellwig

nvmet: get transport reference for passthru ctrl

Grab a reference to the transport driver to ensure it can't be unloaded
while a passthrough controller is active.

Fixes: c1fef73f ("nvmet: add passthru code to process commands")
Reported-by: default avatarChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarLogan Gunthorpe <logang@deltatee.com>
parent 52a3974f
...@@ -517,6 +517,7 @@ int nvmet_passthru_ctrl_enable(struct nvmet_subsys *subsys) ...@@ -517,6 +517,7 @@ int nvmet_passthru_ctrl_enable(struct nvmet_subsys *subsys)
subsys->ver = NVME_VS(1, 2, 1); subsys->ver = NVME_VS(1, 2, 1);
} }
__module_get(subsys->passthru_ctrl->ops->module);
mutex_unlock(&subsys->lock); mutex_unlock(&subsys->lock);
return 0; return 0;
...@@ -531,6 +532,7 @@ static void __nvmet_passthru_ctrl_disable(struct nvmet_subsys *subsys) ...@@ -531,6 +532,7 @@ static void __nvmet_passthru_ctrl_disable(struct nvmet_subsys *subsys)
{ {
if (subsys->passthru_ctrl) { if (subsys->passthru_ctrl) {
xa_erase(&passthru_subsystems, subsys->passthru_ctrl->cntlid); xa_erase(&passthru_subsystems, subsys->passthru_ctrl->cntlid);
module_put(subsys->passthru_ctrl->ops->module);
nvme_put_ctrl(subsys->passthru_ctrl); nvme_put_ctrl(subsys->passthru_ctrl);
} }
subsys->passthru_ctrl = NULL; subsys->passthru_ctrl = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment