From 7fce856f1180c2db3c9f5a88b04bb7124a20cb21 Mon Sep 17 00:00:00 2001 From: Max Gurtovoy Date: Wed, 24 Sep 2025 23:35:44 +0300 Subject: [PATCH] nvmet: add sanity checks when freeing subsystem Add WARN_ON_ONCE checks in nvmet_subsys_free() to ensure that the ctrls and hosts lists are all empty during subsystem release. This helps catch resource leaks. Signed-off-by: Max Gurtovoy Signed-off-by: Keith Busch --- drivers/nvme/target/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c index 5d7d483bfbe37..9de429a3f0d89 100644 --- a/drivers/nvme/target/core.c +++ b/drivers/nvme/target/core.c @@ -1903,6 +1903,8 @@ static void nvmet_subsys_free(struct kref *ref) struct nvmet_subsys *subsys = container_of(ref, struct nvmet_subsys, ref); + WARN_ON_ONCE(!list_empty(&subsys->ctrls)); + WARN_ON_ONCE(!list_empty(&subsys->hosts)); WARN_ON_ONCE(!xa_empty(&subsys->namespaces)); nvmet_debugfs_subsys_free(subsys); -- 2.47.3