Skip to content

Commit 80d7762

Browse files
Zheng QixingChristoph Hellwig
authored andcommitted
nvme: fix inconsistent RCU list manipulation in nvme_ns_add_to_ctrl_list()
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: be647e2 ("nvme: use srcu for iterating namespace list") Signed-off-by: Zheng Qixing <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 3051247 commit 80d7762

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/nvme/host/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4077,7 +4077,7 @@ static void nvme_ns_add_to_ctrl_list(struct nvme_ns *ns)
40774077
return;
40784078
}
40794079
}
4080-
list_add(&ns->list, &ns->ctrl->namespaces);
4080+
list_add_rcu(&ns->list, &ns->ctrl->namespaces);
40814081
}
40824082

40834083
static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info)

0 commit comments

Comments
 (0)