From: Yuho Choi <oss.patchbox@gmail.com>
To: Marcel Holtmann <marcel@holtmann.org>,
Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
Yuho Choi <oss.patchbox@gmail.com>,
stable@vger.kernel.org
Subject: [PATCH v1] Bluetooth: virtio_bt: Fix probe error cleanup
Date: Thu, 10 Sep 2026 22:41:24 -0400 [thread overview]
Message-ID: <20260911024124.1527637-1-oss.patchbox@gmail.com> (raw)
Once hci_register_dev() succeeds, the HCI device is published, a
registration reference is held, and power-on work is queued. If
virtbt_open_vdev() fails, the error path only drops the caller's
reference before deleting the virtqueues.
The registration reference keeps the HCI device and its callbacks alive.
Therefore, a later HCI send can dereference a freed virtqueue through
vbt->vqs.
Unregister the HCI device to withdraw it and drain its work before
resetting the virtio device, reclaiming queued buffers, and deleting the
virtqueues. Also, free vbt on every probe error path.
Fixes: afd2daa26c7a ("Bluetooth: Add support for virtio transport driver")
Fixes: dc65b4b0f90a ("Bluetooth: virtio_bt: fix device removal")
Cc: stable@vger.kernel.org # 6.2+
Signed-off-by: Yuho Choi <oss.patchbox@gmail.com>
---
drivers/bluetooth/virtio_bt.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/drivers/bluetooth/virtio_bt.c b/drivers/bluetooth/virtio_bt.c
index c20d54088c8c..8c55b538deef 100644
--- a/drivers/bluetooth/virtio_bt.c
+++ b/drivers/bluetooth/virtio_bt.c
@@ -315,12 +315,12 @@ static int virtbt_probe(struct virtio_device *vdev)
err = virtio_find_vqs(vdev, VIRTBT_NUM_VQS, vbt->vqs, vqs_info, NULL);
if (err)
- return err;
+ goto err_free_vbt;
hdev = hci_alloc_dev();
if (!hdev) {
err = -ENOMEM;
- goto failed;
+ goto err_del_vqs;
}
vbt->hdev = hdev;
@@ -390,20 +390,25 @@ static int virtbt_probe(struct virtio_device *vdev)
if (hci_register_dev(hdev) < 0) {
hci_free_dev(hdev);
err = -EBUSY;
- goto failed;
+ goto err_del_vqs;
}
virtio_device_ready(vdev);
err = virtbt_open_vdev(vbt);
- if (err)
- goto open_failed;
+ if (err) {
+ hci_unregister_dev(hdev);
+ virtio_reset_device(vdev);
+ virtbt_close_vdev(vbt);
+ hci_free_dev(hdev);
+ goto err_del_vqs;
+ }
return 0;
-open_failed:
- hci_free_dev(hdev);
-failed:
+err_del_vqs:
vdev->config->del_vqs(vdev);
+err_free_vbt:
+ kfree(vbt);
return err;
}
--
2.43.0
reply other threads:[~2026-09-11 2:41 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=20260911024124.1527637-1-oss.patchbox@gmail.com \
--to=oss.patchbox@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=stable@vger.kernel.org \
/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
all inboxes | Powered by JetHome®