Commit 7fce856f authored by Max Gurtovoy's avatar Max Gurtovoy Committed by Keith Busch
Browse files

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: default avatarMax Gurtovoy <mgurtovoy@nvidia.com>
Signed-off-by: default avatarKeith Busch <kbusch@kernel.org>
parent d211a280
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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);