nvmet: add sanity checks when freeing subsystem
Subsystems (2)
PATCH 1/1 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 <[email protected]>
--- drivers/nvme/target/core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/nvme/target/core.c +2 -0
@@ -1929,6 +1929,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);
Signature · 1 line
2.18.1
Keith Busch
maintainerQuoted 3 lines · Max Gurtovoy
Add
WARN_ON_ONCEchecks innvmet_subsys_free()to ensure that the ctrls and hosts lists are all empty during subsystem release. This helps catch resource leaks.
Looks good, applied to nvme-6.18.