From: Yi Cong <cong.yi@linux.dev>
To: marcel@holtmann.org, luiz.dentz@gmail.com
Cc: linux-bluetooth@vger.kernel.org, stable@vger.kernel.org,
Yi Cong <yicong@kylinos.cn>
Subject: [PATCH 1/2] Bluetooth: virtio_bt: fix leak of vbt on virtio_find_vqs failure
Date: Tue, 11 Aug 2026 11:27:01 +0800 [thread overview]
Message-ID: <20260811032702.67908-2-cong.yi@linux.dev> (raw)
In-Reply-To: <20260811032702.67908-1-cong.yi@linux.dev>
From: Yi Cong <yicong@kylinos.cn>
If virtio_find_vqs() fails, the function returns without freeing the
allocated 'vbt' or clearing 'vdev->priv'. Add a 'free_priv' label to
release them, and let 'failed' fall through to it.
Fixes: afd2daa26c7a ("Bluetooth: Add support for virtio transport driver")
Cc: stable@vger.kernel.org
Signed-off-by: Yi Cong <yicong@kylinos.cn>
---
drivers/bluetooth/virtio_bt.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/bluetooth/virtio_bt.c b/drivers/bluetooth/virtio_bt.c
index c20d54088c8c4..b674fe0c2779e 100644
--- a/drivers/bluetooth/virtio_bt.c
+++ b/drivers/bluetooth/virtio_bt.c
@@ -315,7 +315,7 @@ 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 free_priv;
hdev = hci_alloc_dev();
if (!hdev) {
@@ -404,6 +404,9 @@ static int virtbt_probe(struct virtio_device *vdev)
hci_free_dev(hdev);
failed:
vdev->config->del_vqs(vdev);
+free_priv:
+ vdev->priv = NULL;
+ kfree(vbt);
return err;
}
--
2.25.1
next prev parent reply other threads:[~2026-08-11 3:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 3:27 [PATCH 0/2] Bluetooth: virtio_bt: harden probe error paths Yi Cong
2026-08-11 3:27 ` Yi Cong [this message]
2026-08-11 4:45 ` bluez.test.bot
2026-08-11 3:27 ` [PATCH 2/2] Bluetooth: virtio_bt: unregister hdev before freeing on open failure Yi Cong
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=20260811032702.67908-2-cong.yi@linux.dev \
--to=cong.yi@linux.dev \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=stable@vger.kernel.org \
--cc=yicong@kylinos.cn \
/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