summaryrefslogtreecommitdiff
path: root/drivers/nvme/target
diff options
context:
space:
mode:
authorRoy Shterman <roys@lightbitslabs.com>2017-12-25 15:18:30 +0300
committerChristoph Hellwig <hch@lst.de>2018-01-08 13:01:56 +0300
commit0de5cd367c6aa2a31a1c931628f778f79f8ef22e (patch)
tree3238baff9012d5248e023446cb71dbfafbe77821 /drivers/nvme/target
parent9ce1f2e12e017607fe17a67cea79ebcf0184e5b3 (diff)
downloadlinux-0de5cd367c6aa2a31a1c931628f778f79f8ef22e.tar.xz
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/target')
-rw-r--r--drivers/nvme/target/loop.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c
index 1e21b286f299..fdfcc961029f 100644
--- a/drivers/nvme/target/loop.c
+++ b/drivers/nvme/target/loop.c
@@ -686,6 +686,7 @@ static struct nvmet_fabrics_ops nvme_loop_ops = {
static struct nvmf_transport_ops nvme_loop_transport = {
.name = "loop",
+ .module = THIS_MODULE,
.create_ctrl = nvme_loop_create_ctrl,
};