2022-03-07 18:34:22

by Tom Rix

[permalink] [raw]
Subject: [PATCH] virtio_ring: Initialize vring_size_in_bytes

From: Tom Rix <[email protected]>

On the clang build, there is this error
virtio_ring.c:1772:26: error: variable 'ring_size_in_bytes'
is uninitialized when used here
vring_free_queue(vdev, ring_size_in_bytes,
^~~~~~~~~~~~~~~~~~

ring_dma_addr was intialized twice, once with the ring_size_in_bytes.
value. So fix typo.

Signed-off-by: Tom Rix <[email protected]>
---
drivers/virtio/virtio_ring.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 905c882600618..b2b567ebb9120 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -1756,7 +1756,7 @@ static void vring_free_vring_packed(struct vring_packed *vring,
ring = vring->ring;
driver = vring->driver;
device = vring->device;
- ring_dma_addr = vring->ring_size_in_bytes;
+ ring_size_in_bytes = vring->ring_size_in_bytes;
event_size_in_bytes = vring->event_size_in_bytes;
ring_dma_addr = vring->ring_dma_addr;
driver_event_dma_addr = vring->driver_event_dma_addr;
--
2.26.3


2022-03-09 01:13:36

by Nathan Chancellor

[permalink] [raw]
Subject: Re: [PATCH] virtio_ring: Initialize vring_size_in_bytes

On Mon, Mar 07, 2022 at 09:49:16AM -0800, [email protected] wrote:
> From: Tom Rix <[email protected]>
>
> On the clang build, there is this error
> virtio_ring.c:1772:26: error: variable 'ring_size_in_bytes'
> is uninitialized when used here
> vring_free_queue(vdev, ring_size_in_bytes,
> ^~~~~~~~~~~~~~~~~~
>
> ring_dma_addr was intialized twice, once with the ring_size_in_bytes.
> value. So fix typo.
>
> Signed-off-by: Tom Rix <[email protected]>

I was getting ready to send the same patch.

Reviewed-by: Nathan Chancellor <[email protected]>

> ---
> drivers/virtio/virtio_ring.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> index 905c882600618..b2b567ebb9120 100644
> --- a/drivers/virtio/virtio_ring.c
> +++ b/drivers/virtio/virtio_ring.c
> @@ -1756,7 +1756,7 @@ static void vring_free_vring_packed(struct vring_packed *vring,
> ring = vring->ring;
> driver = vring->driver;
> device = vring->device;
> - ring_dma_addr = vring->ring_size_in_bytes;
> + ring_size_in_bytes = vring->ring_size_in_bytes;
> event_size_in_bytes = vring->event_size_in_bytes;
> ring_dma_addr = vring->ring_dma_addr;
> driver_event_dma_addr = vring->driver_event_dma_addr;
> --
> 2.26.3
>
>