[PATCH 1/1] nvme: correctly account for namespace head reference counter
Daniel Wagner
dwagner at suse.de
Mon Jun 23 01:18:09 PDT 2025
Hi Nilay,
On Fri, Jun 20, 2025 at 01:32:43PM +0530, Nilay Shroff wrote:
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -4089,6 +4089,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info)
> struct nvme_ns *ns;
> struct gendisk *disk;
> int node = ctrl->numa_node;
> + bool last_path = false;
>
> ns = kzalloc_node(sizeof(*ns), GFP_KERNEL, node);
> if (!ns)
> @@ -4181,9 +4182,13 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info)
> out_unlink_ns:
> mutex_lock(&ctrl->subsys->lock);
> list_del_rcu(&ns->siblings);
> - if (list_empty(&ns->head->list))
> + if (list_empty(&ns->head->list)) {
> list_del_init(&ns->head->entry);
> + last_path = true;
> + }
> mutex_unlock(&ctrl->subsys->lock);
> + if (last_path)
> + nvme_put_ns_head(ns->head);
> nvme_put_ns_head(ns->head);
Could the put moved in front of 'goto out_unlink_ns'?
Thanks,
Daniel
More information about the Linux-nvme
mailing list