]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
nvmet: add sanity checks when freeing subsystem
authorMax Gurtovoy <mgurtovoy@nvidia.com>
Wed, 24 Sep 2025 20:35:44 +0000 (23:35 +0300)
committerKeith Busch <kbusch@kernel.org>
Mon, 1 Dec 2025 16:53:17 +0000 (08:53 -0800)
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>
drivers/nvme/target/core.c

index 5d7d483bfbe372406869181b9b1fc56afd3f6846..9de429a3f0d893d73c2dc7f4b37e0429a59217a6 100644 (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);