]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
nvme-fc: release admin tagset if init fails
authorChaitanya Kulkarni <ckulkarnilinux@gmail.com>
Sat, 20 Dec 2025 00:18:42 +0000 (16:18 -0800)
committerKeith Busch <kbusch@kernel.org>
Fri, 9 Jan 2026 14:55:12 +0000 (06:55 -0800)
nvme_fabrics creates an NVMe/FC controller in following path:

    nvmf_dev_write()
      -> nvmf_create_ctrl()
        -> nvme_fc_create_ctrl()
          -> nvme_fc_init_ctrl()

nvme_fc_init_ctrl() allocates the admin blk-mq resources right after
nvme_add_ctrl() succeeds.  If any of the subsequent steps fail (changing
the controller state, scheduling connect work, etc.), we jump to the
fail_ctrl path, which tears down the controller references but never
frees the admin queue/tag set.  The leaked blk-mq allocations match the
kmemleak report seen during blktests nvme/fc.

Check ctrl->ctrl.admin_tagset in the fail_ctrl path and call
nvme_remove_admin_tag_set() when it is set so that all admin queue
allocations are reclaimed whenever controller setup aborts.

Reported-by: Yi Zhang <yi.zhang@redhat.com>
Reviewed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Chaitanya Kulkarni <ckulkarnilinux@gmail.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/host/fc.c

index bc455fa982462c0fed73ce70def97e06abb14285..6948de3f438ae060cca73753215548faf9648e84 100644 (file)
@@ -3587,6 +3587,8 @@ fail_ctrl:
 
        ctrl->ctrl.opts = NULL;
 
+       if (ctrl->ctrl.admin_tagset)
+               nvme_remove_admin_tag_set(&ctrl->ctrl);
        /* initiate nvme ctrl ref counting teardown */
        nvme_uninit_ctrl(&ctrl->ctrl);