From: Max Gurtovoy Date: Wed, 24 Sep 2025 20:35:44 +0000 (+0300) Subject: nvmet: add sanity checks when freeing subsystem X-Git-Tag: v6.19-rc1~50^2^2~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7fce856f1180c2db3c9f5a88b04bb7124a20cb21;p=thirdparty%2Fkernel%2Flinux.git 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 --- 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);