Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] nvmet: add sanity checks when freeing subsystem
@ 2025-09-24 20:35 Max Gurtovoy
  2025-09-24 22:14 ` Keith Busch
  0 siblings, 1 reply; 2+ messages in thread
From: Max Gurtovoy @ 2025-09-24 20:35 UTC (permalink / raw)
  To: hch, linux-nvme, kbusch, sagi, kch; +Cc: israelr, Max Gurtovoy

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>
---
 drivers/nvme/target/core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index b64fcd2cd92b..61625d692c90 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -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);
-- 
2.18.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1] nvmet: add sanity checks when freeing subsystem
  2025-09-24 20:35 [PATCH 1/1] nvmet: add sanity checks when freeing subsystem Max Gurtovoy
@ 2025-09-24 22:14 ` Keith Busch
  0 siblings, 0 replies; 2+ messages in thread
From: Keith Busch @ 2025-09-24 22:14 UTC (permalink / raw)
  To: Max Gurtovoy; +Cc: hch, linux-nvme, sagi, kch, israelr

On Wed, Sep 24, 2025 at 11:35:44PM +0300, Max Gurtovoy wrote:
> 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.

Looks good, applied to nvme-6.18.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-09-24 22:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-24 20:35 [PATCH 1/1] nvmet: add sanity checks when freeing subsystem Max Gurtovoy
2025-09-24 22:14 ` Keith Busch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox