[PATCH] nvme: fix admin request_queue lifetime

Chaitanya Kulkarni chaitanyak at nvidia.com
Wed Nov 5 16:10:22 PST 2025


On 11/5/25 12:31, Keith Busch wrote:
> On Wed, Nov 05, 2025 at 12:21:14PM -0800, Casey Chen wrote:
>> On Tue, Nov 4, 2025 at 3:00 PM Keith Busch <kbusch at meta.com> wrote:
>>> @@ -5045,6 +5044,7 @@ static void nvme_free_ctrl(struct device *dev)
>>>                  container_of(dev, struct nvme_ctrl, ctrl_device);
>>>          struct nvme_subsystem *subsys = ctrl->subsys;
>>>
>>> +       blk_put_queue(ctrl->admin_q);
>> Wait. Do we need to check ctrl->admin_q non-NULL before putting it ?
>> If nvme_alloc_admin_tag_set() fails, blk_put_queue() would put NULL
>> and panic kernel.
> Oh, like if we call nvme_uninit_ctrl() prior to allocating the tagset?
> Yes, I think you're right, unlikely as that is to occur. Thanks, I'll
> fold in your suggestion.

I had that check in the patch I posted earlier :)

"""""""

+    /**
+     * Release admin_q's final reference. All namespace references have
+     * been released at this point. NULL check is needed for to handle
+     * allocation failure in nvme_alloc_admin_tag_set().
+     */
+    if (ctrl->admin_q)
+        blk_put_queue(ctrl->admin_q);
+
        if (!subsys || ctrl->instance != subsys->instance)
            ida_free(&nvme_instance_ida, ctrl->instance);
        nvme_free_cels(ctrl);

-ck

""""""

-ck




More information about the Linux-nvme mailing list