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 <mgurtovoy@nvidia.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
This commit is contained in:
Max Gurtovoy 2025-09-24 23:35:44 +03:00 committed by Keith Busch
parent d211a28035
commit 7fce856f11

View File

@ -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);