[PATCH 1/1] nvmet: add safety check for subsys lock during nvmet_p2pmem_ns_add_p2p
Max Gurtovoy
mgurtovoy at nvidia.com
Sat Sep 20 17:08:51 PDT 2025
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.
Signed-off-by: Max Gurtovoy <mgurtovoy at nvidia.com>
---
drivers/nvme/target/core.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index 7ee12819e2b5..79104f5ce40a 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -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;
--
2.18.1
More information about the Linux-nvme
mailing list