Skip to contentSkip to conversation

nvmet: add safety check for subsys lock during nvmet_p2pmem_ns_add_p2p

PATCH Superseded Max Gurtovoy 1 participant 1 message Sep 21, 2025

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvmet: add safety check for subsys lock during nvmet_p2pmem_ns_add_p2p

Replace comment about required lock with a lockdep_assert_held() check in nvmet_p2pmem_ns_add_p2p(). This ensures the subsystem lock is held at runtime.

---
 drivers/nvme/target/core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/nvme/target/core.c +2 -3
index 7ee12819e2b5..79104f5ce40a 100644
@@ -541,9 +541,6 @@ static int nvmet_p2pmem_ns_enable(struct nvmet_ns *ns)
 	return 0;
 }
 
-/*
- * Note: ctrl->subsys->lock should be held when calling this function
- */
 static void nvmet_p2pmem_ns_add_p2p(struct nvmet_ctrl *ctrl,
 				    struct nvmet_ns *ns)
 {
@@ -551,6 +548,8 @@ static void nvmet_p2pmem_ns_add_p2p(struct nvmet_ctrl *ctrl,
 	struct pci_dev *p2p_dev;
 	int ret;
 
+	lockdep_assert_held(&ctrl->subsys->lock);
+
 	if (!ctrl->p2p_client || !ns->use_p2pmem)
 		return;
 
Signature · 1 line
2.18.1