From: sashiko-bot@kernel.org
To: "Saravanan D" <saravanand@crusoe.ai>, linux-nvme@lists.infradead.org
Subject: Re: [PATCH v7 1/2] nvme: add per-queue sysfs directories
Date: Wed, 04 Nov 2026 14:17:33 +0000 [thread overview]
Message-ID: <sashiko-outbox-197419@kernel.org> (raw)
In-Reply-To: <656dac7329c8452efe786b0c76a3b8c0bbf53159.1793800758.git.saravanand@crusoe.ai>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] nvme: missing kobject_del() on error path in nvme_add_queue_info()
--
commit 6e5f76664582ac2e5b614fa65fb1066286cd6645
Author: Saravanan D <saravanand@crusoe.ai>
nvme: add per-queue sysfs directories
This commit adds helpers to create a per-controller queues sysfs directory
and manage per-queue subdirectories (/sys/class/nvme/nvmeX/queues/<qid>/)
populated with transport-provided attribute groups.
Link: https://lore.kernel.org/linux-nvme/13c160d0-0657-47ce-9a16-58d348267ab0@grimberg.me/
> diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c
> index 10018c6356b62..8a982453cb69d 100644
> --- a/drivers/nvme/host/sysfs.c
> +++ b/drivers/nvme/host/sysfs.c
[ ... ]
> +struct nvme_queue_info *
> +nvme_add_queue_info(struct nvme_ctrl *ctrl, unsigned int qid, void *data)
> +{
> + struct nvme_queue_info *qinfo;
> + int ret;
> +
> + if (WARN_ON_ONCE(!ctrl->queues_kobj))
> + return ERR_PTR(-EINVAL);
> +
> + qinfo = kzalloc_obj(*qinfo);
> + if (!qinfo)
> + return ERR_PTR(-ENOMEM);
> + qinfo->data = data;
> +
> + ret = kobject_init_and_add(&qinfo->kobj, &nvme_queue_info_ktype,
> + ctrl->queues_kobj, "%u", qid);
> + if (ret)
> + goto out_put;
> +
> + ret = sysfs_create_groups(&qinfo->kobj, ctrl->ops->queue_attr_groups);
> + if (ret)
> + goto out_put;
> + return qinfo;
> +
> +out_put:
> + kobject_put(&qinfo->kobj);
> + return ERR_PTR(ret);
> +}
[Severity: Medium]
If sysfs_create_groups() fails in nvme_add_queue_info() after
kobject_init_and_add() has already published qinfo->kobj in sysfs, should
the error path call kobject_del(&qinfo->kobj) before kobject_put(&qinfo->kobj),
just like nvme_remove_queue_info() does?
Without kobject_del(), unlinking the directory from sysfs is deferred to
kobject_cleanup(). If CONFIG_DEBUG_KOBJECT_RELEASE is enabled or if another
thread grabbed a reference to qinfo->kobj after it was added to sysfs, the
<qid> directory and its parent reference on ctrl->queues_kobj remain live
after nvme_add_queue_info() returns an error, which can cause a subsequent
retry or reconnect for the same qid to fail with -EEXIST or expose a
dangling qinfo->data pointer.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1793800758.git.saravanand@crusoe.ai?part=1
next prev parent reply other threads:[~2026-11-04 14:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 14:06 [PATCH v7 0/2] nvme-tcp: allow setting per-queue io_cpu through sysfs Saravanan D
2026-11-04 14:06 ` [PATCH v7 1/2] nvme: add per-queue sysfs directories Saravanan D
2026-11-04 14:17 ` sashiko-bot [this message]
2026-11-04 18:51 ` Saravanan D
2026-11-04 17:30 ` Daniel Wagner
2026-11-06 5:23 ` Saravanan D
2026-11-04 14:06 ` [PATCH v7 2/2] nvme-tcp: allow setting per-queue io_cpu through sysfs Saravanan D
2026-11-04 14:07 ` [PATCH blktests] nvme/077: test the per-queue io_cpu sysfs attribute Saravanan D
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-197419@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=saravanand@crusoe.ai \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox