nvmet: add safety check for subsystem lock during nvmet_ns_changed
authorMax Gurtovoy <maxg@mellanox.com>
Tue, 2 Apr 2019 11:51:54 +0000 (14:51 +0300)
committerChristoph Hellwig <hch@lst.de>
Fri, 5 Apr 2019 06:07:58 +0000 (08:07 +0200)
we need to make sure that subsystem lock is taken during ctrl's list
traversing. nvmet_ns_changed function is not static and can be used from
various callers simultaneously.

Signed-off-by: Max Gurtovoy <maxg@mellanox.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/target/core.c

index 4dc388a2ecb0121f8ddb6911476abb9e011761c6..4d8dd29479c0717556f4cf4f9e7a3110546b6ef8 100644 (file)
@@ -214,6 +214,8 @@ void nvmet_ns_changed(struct nvmet_subsys *subsys, u32 nsid)
 {
        struct nvmet_ctrl *ctrl;
 
+       lockdep_assert_held(&subsys->lock);
+
        list_for_each_entry(ctrl, &subsys->ctrls, subsys_entry) {
                nvmet_add_to_changed_ns_log(ctrl, cpu_to_le32(nsid));
                if (nvmet_aen_bit_disabled(ctrl, NVME_AEN_BIT_NS_ATTR))