From: Yuho Choi <oss.patchbox@gmail.com>
To: Pankaj Gupta <pankaj.gupta.linux@gmail.com>,
Dan Williams <djbw@kernel.org>,
Vishal Verma <vishal.l.verma@intel.com>,
Dave Jiang <dave.jiang@intel.com>,
Alison Schofield <alison.schofield@intel.com>
Cc: Ira Weiny <iweiny@kernel.org>,
"Michael S . Tsirkin" <mst@redhat.com>,
nvdimm@lists.linux.dev, virtualization@lists.linux.dev,
linux-kernel@vger.kernel.org, Yuho Choi <oss.patchbox@gmail.com>
Subject: [PATCH] nvdimm: virtio_pmem: reset the device if nvdimm_bus_register() fails
Date: Thu, 3 Dec 2026 05:07:44 +0000 [thread overview]
Message-ID: <20261203050747.1683432-2-oss.patchbox@gmail.com> (raw)
init_vq() enables the request queue on the device. If
nvdimm_bus_register() then fails, probe deletes the queue without
resetting the device, so the queue stays enabled and the next probe of
the device fails in setup_vq() with -ENOENT. Reset the device before
deleting the queue, as the later error path and remove() do.
Fixes: 6e84200c0a29 ("virtio-pmem: Add virtio pmem driver")
Signed-off-by: Yuho Choi <oss.patchbox@gmail.com>
---
I used an LLM to write and run the test below.
Tested on d06ce6f1eb5e in a QEMU/KVM guest with a virtio-pmem-pci device
and KASAN. A test-only module parameter made nvdimm_bus_register() fail
in the first probe; after clearing it, binding the driver again gave
(3 of 3 runs each):
without this patch:
virtio_pmem virtio0: failed to initialize virtio pmem vq's
virtio_pmem virtio0: probe with driver virtio_pmem failed with error -2
with this patch:
the bind succeeds and nd_pmem namespace0.0 is created
No KASAN reports in any run.
drivers/nvdimm/virtio_pmem.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/nvdimm/virtio_pmem.c b/drivers/nvdimm/virtio_pmem.c
index 3e06ff34c4af..e2b7fe50d181 100644
--- a/drivers/nvdimm/virtio_pmem.c
+++ b/drivers/nvdimm/virtio_pmem.c
@@ -117,6 +117,7 @@ static int virtio_pmem_probe(struct virtio_device *vdev)
if (!vpmem->nvdimm_bus) {
dev_err(&vdev->dev, "failed to register device with nvdimm_bus\n");
err = -ENXIO;
+ virtio_reset_device(vdev);
goto out_vq;
}
base-commit: d06ce6f1eb5eeffd4ebcfde345dc34a98131d106
--
2.56.1
reply other threads:[~2026-12-03 5:07 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261203050747.1683432-2-oss.patchbox@gmail.com \
--to=oss.patchbox@gmail.com \
--cc=alison.schofield@intel.com \
--cc=dave.jiang@intel.com \
--cc=djbw@kernel.org \
--cc=iweiny@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=nvdimm@lists.linux.dev \
--cc=pankaj.gupta.linux@gmail.com \
--cc=virtualization@lists.linux.dev \
--cc=vishal.l.verma@intel.com \
/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