summaryrefslogtreecommitdiffstats
path: root/drivers/nvme/host/fc.c
diff options
context:
space:
mode:
authorRoy Shterman2017-12-25 13:18:30 +0100
committerChristoph Hellwig2018-01-08 11:01:56 +0100
commit0de5cd367c6aa2a31a1c931628f778f79f8ef22e (patch)
tree3238baff9012d5248e023446cb71dbfafbe77821 /drivers/nvme/host/fc.c
parentnvmet-fc: cleanup nvmet add_port/remove_port (diff)
downloadkernel-qcow2-linux-0de5cd367c6aa2a31a1c931628f778f79f8ef22e.tar.gz
kernel-qcow2-linux-0de5cd367c6aa2a31a1c931628f778f79f8ef22e.tar.xz
kernel-qcow2-linux-0de5cd367c6aa2a31a1c931628f778f79f8ef22e.zip
nvme-fabrics: protect against module unload during create_ctrl
NVMe transport driver module unload may (and usually does) trigger iteration over the active controllers and delete them all (sometimes under a mutex). However, a controller can be created concurrently with module unload which can lead to leakage of resources (most important char device node leakage) in case the controller creation occured after the unload delete and drain sequence. To protect against this, we take a module reference to guarantee that the nvme transport driver is not unloaded while creating a controller. Signed-off-by: Roy Shterman <roys@lightbitslabs.com> Signed-off-by: Sagi Grimberg <sagi@grimberg.me> Reviewed-by: Max Gurtovoy <maxg@mellanox.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/nvme/host/fc.c')
-rw-r--r--drivers/nvme/host/fc.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index 0a8af4daef89..2a7a9a75105d 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -3381,6 +3381,7 @@ nvme_fc_create_ctrl(struct device *dev, struct nvmf_ctrl_options *opts)
static struct nvmf_transport_ops nvme_fc_transport = {
.name = "fc",
+ .module = THIS_MODULE,
.required_opts = NVMF_OPT_TRADDR | NVMF_OPT_HOST_TRADDR,
.allowed_opts = NVMF_OPT_RECONNECT_DELAY | NVMF_OPT_CTRL_LOSS_TMO,
.create_ctrl = nvme_fc_create_ctrl,