From: Kuan-Wei Chiu <visitorckw@gmail.com>
To: Bin Meng <bin.meng@processmission.com>
Cc: "U-Boot Mailing List" <u-boot@lists.u-boot-project.org>,
"Bin Meng" <bmeng.cn@gmail.com>,
"Christian Pötzsch" <christian.poetzsch@kernkonzept.com>,
"Daniel Palmer" <daniel@thingy.jp>,
"Simon Glass" <sjg@chromium.org>, "Tom Rini" <trini@konsulko.com>
Subject: Re: [PATCH 6/8] virtio: blk: Validate configuration before creating the virtqueue
Date: Tue, 27 Oct 2026 15:02:42 +0800 [thread overview]
Message-ID: <auBMkr3_OfEdrqTC@google.com> (raw)
In-Reply-To: <20261015111328.1269775-7-bin.meng@processmission.com>
On Thu, Oct 15, 2026 at 07:13:21PM +0800, Bin Meng wrote:
> The block driver allocates its virtqueue before checking the advertised
> block size. An invalid size makes probe return -EIO without releasing
> the queue, causing a memory leak.
>
> Change to read and validate the configuration before allocating the
> virtqueue instead.
>
> Signed-off-by: Bin Meng <bin.meng@processmission.com>
Reviewed-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Regards,
Kuan-Wei
> ---
>
> drivers/virtio/virtio_blk.c | 7 +------
> 1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/drivers/virtio/virtio_blk.c b/drivers/virtio/virtio_blk.c
> index 404d9140cb2..3d5d29f00df 100644
> --- a/drivers/virtio/virtio_blk.c
> +++ b/drivers/virtio/virtio_blk.c
> @@ -251,13 +251,8 @@ static int virtio_blk_probe(struct udevice *dev)
> struct virtio_blk_priv *priv = dev_get_priv(dev);
> struct blk_desc *desc = dev_get_uclass_plat(dev);
> u64 cap;
> - int ret;
> u32 blk_size;
>
> - ret = virtio_find_vqs(dev, 1, &priv->vq);
> - if (ret)
> - return ret;
> -
> virtio_cread(dev, struct virtio_blk_config, capacity, &cap);
> desc->lba = cap;
> if (virtio_has_feature(dev, VIRTIO_BLK_F_BLK_SIZE)) {
> @@ -281,7 +276,7 @@ static int virtio_blk_probe(struct udevice *dev)
> else
> priv->seg_max = -1U;
>
> - return 0;
> + return virtio_find_vqs(dev, 1, &priv->vq);
> }
>
> static const struct blk_ops virtio_blk_ops = {
> --
> 2.53.0
>
>
next prev parent reply other threads:[~2026-10-27 7:02 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 11:13 [PATCH 0/8] virtio: Fix virtqueue teardown and probe cleanup Bin Meng
2026-10-15 11:13 ` [PATCH 1/8] virtio: mmio: Fix private data lookup when deleting queues Bin Meng
2026-10-16 14:10 ` Simon Glass
2026-10-27 6:48 ` Kuan-Wei Chiu
2026-10-15 11:13 ` [PATCH 2/8] virtio: pci: Fix legacy " Bin Meng
2026-10-16 14:34 ` Simon Glass
2026-10-27 7:02 ` Kuan-Wei Chiu
2026-10-15 11:13 ` [PATCH 3/8] virtio: pci: Fix modern " Bin Meng
2026-10-16 14:34 ` Simon Glass
2026-10-27 7:02 ` Kuan-Wei Chiu
2026-10-15 11:13 ` [PATCH 4/8] virtio: Release virtqueues after device reset Bin Meng
2026-10-16 14:34 ` Simon Glass
2026-10-27 6:49 ` Kuan-Wei Chiu
2026-10-15 11:13 ` [PATCH 5/8] virtio: 9p: Reset the device before releasing its queues Bin Meng
2026-10-16 14:34 ` Simon Glass
2026-10-27 6:50 ` Kuan-Wei Chiu
2026-10-15 11:13 ` [PATCH 6/8] virtio: blk: Validate configuration before creating the virtqueue Bin Meng
2026-10-16 14:34 ` Simon Glass
2026-10-27 7:02 ` Kuan-Wei Chiu [this message]
2026-10-15 11:13 ` [PATCH 7/8] MAINTAINERS: Cover all virtio driver-model tests Bin Meng
2026-10-15 11:18 ` Quentin Schulz
2026-10-16 14:34 ` Simon Glass
2026-10-15 11:13 ` [PATCH 8/8] test: dm: Check virtio queue cleanup on device removal Bin Meng
2026-10-16 14:34 ` Simon Glass
2026-10-29 22:17 ` [PATCH 0/8] virtio: Fix virtqueue teardown and probe cleanup Tom Rini
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=auBMkr3_OfEdrqTC@google.com \
--to=visitorckw@gmail.com \
--cc=bin.meng@processmission.com \
--cc=bmeng.cn@gmail.com \
--cc=christian.poetzsch@kernkonzept.com \
--cc=daniel@thingy.jp \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.u-boot-project.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