summaryrefslogtreecommitdiff
path: root/drivers/nvme
diff options
context:
space:
mode:
authorZheng Qixing <zhengqixing@huawei.com>2025-07-01 15:17:17 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-07-24 08:56:30 +0200
commit8184ee3c667db18ecaed5e74ef9618f47c4c0b3e (patch)
tree8a24679ba32591d9f1a52cfab6711d8e8b7b6b14 /drivers/nvme
parent9a7de97b915ad264f1c040807aa6e414bd983cbb (diff)
downloadlinux-8184ee3c667db18ecaed5e74ef9618f47c4c0b3e.tar.gz
linux-8184ee3c667db18ecaed5e74ef9618f47c4c0b3e.tar.bz2
linux-8184ee3c667db18ecaed5e74ef9618f47c4c0b3e.zip
nvme: fix inconsistent RCU list manipulation in nvme_ns_add_to_ctrl_list()
[ Upstream commit 80d7762e0a42307ee31b21f090e21349b98c14f6 ] When inserting a namespace into the controller's namespace list, the function uses list_add_rcu() when the namespace is inserted in the middle of the list, but falls back to a regular list_add() when adding at the head of the list. This inconsistency could lead to race conditions during concurrent access, as users might observe a partially updated list. Fix this by consistently using list_add_rcu() in both code paths to ensure proper RCU protection throughout the entire function. Fixes: be647e2c76b2 ("nvme: use srcu for iterating namespace list") Signed-off-by: Zheng Qixing <zhengqixing@huawei.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/nvme')
-rw-r--r--drivers/nvme/host/core.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index abd42598fc78..2ca14f2b7a0b 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3854,7 +3854,7 @@ static void nvme_ns_add_to_ctrl_list(struct nvme_ns *ns)
return;
}
}
- list_add(&ns->list, &ns->ctrl->namespaces);
+ list_add_rcu(&ns->list, &ns->ctrl->namespaces);
}
static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info)