Skip to content

Commit

Permalink
nvmet: get transport reference for passthru ctrl
Browse files Browse the repository at this point in the history
Grab a reference to the transport driver to ensure it can't be unloaded
while a passthrough controller is active.

Fixes: c1fef73 ("nvmet: add passthru code to process commands")
Reported-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
  • Loading branch information
Christoph Hellwig committed Sep 17, 2020
1 parent 52a3974 commit 3a6b076
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/nvme/target/passthru.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ int nvmet_passthru_ctrl_enable(struct nvmet_subsys *subsys)
subsys->ver = NVME_VS(1, 2, 1);
}

__module_get(subsys->passthru_ctrl->ops->module);
mutex_unlock(&subsys->lock);
return 0;

Expand All @@ -531,6 +532,7 @@ static void __nvmet_passthru_ctrl_disable(struct nvmet_subsys *subsys)
{
if (subsys->passthru_ctrl) {
xa_erase(&passthru_subsystems, subsys->passthru_ctrl->cntlid);
module_put(subsys->passthru_ctrl->ops->module);
nvme_put_ctrl(subsys->passthru_ctrl);
}
subsys->passthru_ctrl = NULL;
Expand Down

0 comments on commit 3a6b076

Please sign in to comment.