* [PATCH] virtio_ring: fix uninitialized used value
@ 2025-07-25 8:36 Jason Wang
2025-07-25 13:11 ` Michael S. Tsirkin
0 siblings, 1 reply; 3+ messages in thread
From: Jason Wang @ 2025-07-25 8:36 UTC (permalink / raw)
To: mst, jasowang
Cc: xuanzhuo, eperezma, virtualization, linux-kernel, Naresh Kamboju,
Randy Dunlap, kernelci . org bot, Linux Kernel Functional Testing
Buildbot reports uninitialized used:
drivers/virtio/virtio_ring.c:2113:40: error: variable 'id' is
uninitialized when used here [-Werror,-Wuninitialized]
2113 | BAD_RING(vq, "id %u out of range\n", id);
| ^~
drivers/virtio/virtio_ring.c:2077:19: note: initialize the variable
'id' to silence this warning
2077 | u16 last_used, id, last_used_idx;
| ^
| = 0
1 error generated.
Fixing this by use last_used instead and drop the complete unused
variable id.
Cc: Naresh Kamboju <naresh.kamboju@linaro.org>
Cc: Randy Dunlap <rdunlap@infradead.org>
Reported-by: kernelci.org bot <bot@kernelci.org>
Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
---
drivers/virtio/virtio_ring.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 8f9413acd4e2..7b960ce9a034 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -2074,7 +2074,7 @@ static void *virtqueue_get_buf_ctx_packed_in_order(struct vring_virtqueue *vq,
void **ctx)
{
unsigned int num = vq->packed.vring.num;
- u16 last_used, id, last_used_idx;
+ u16 last_used, last_used_idx;
bool used_wrap_counter;
void *ret;
@@ -2110,11 +2110,11 @@ static void *virtqueue_get_buf_ctx_packed_in_order(struct vring_virtqueue *vq,
*len = vq->packed.desc_state[last_used].total_len;
if (unlikely(last_used >= num)) {
- BAD_RING(vq, "id %u out of range\n", id);
+ BAD_RING(vq, "id %u out of range\n", last_used);
return NULL;
}
if (unlikely(!vq->packed.desc_state[last_used].data)) {
- BAD_RING(vq, "id %u is not a head!\n", id);
+ BAD_RING(vq, "id %u is not a head!\n", last_used);
return NULL;
}
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] virtio_ring: fix uninitialized used value
2025-07-25 8:36 [PATCH] virtio_ring: fix uninitialized used value Jason Wang
@ 2025-07-25 13:11 ` Michael S. Tsirkin
2025-07-28 3:29 ` Jason Wang
0 siblings, 1 reply; 3+ messages in thread
From: Michael S. Tsirkin @ 2025-07-25 13:11 UTC (permalink / raw)
To: Jason Wang
Cc: xuanzhuo, eperezma, virtualization, linux-kernel, Naresh Kamboju,
Randy Dunlap, kernelci . org bot, Linux Kernel Functional Testing
On Fri, Jul 25, 2025 at 04:36:35PM +0800, Jason Wang wrote:
> Buildbot reports uninitialized used:
>
> drivers/virtio/virtio_ring.c:2113:40: error: variable 'id' is
> uninitialized when used here [-Werror,-Wuninitialized]
> 2113 | BAD_RING(vq, "id %u out of range\n", id);
> | ^~
> drivers/virtio/virtio_ring.c:2077:19: note: initialize the variable
> 'id' to silence this warning
> 2077 | u16 last_used, id, last_used_idx;
> | ^
> | = 0
> 1 error generated.
>
> Fixing this by use last_used instead and drop the complete unused
> variable id.
>
> Cc: Naresh Kamboju <naresh.kamboju@linaro.org>
> Cc: Randy Dunlap <rdunlap@infradead.org>
> Reported-by: kernelci.org bot <bot@kernelci.org>
> Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
I squashed but I think you should respin.
also noticed a couple of minor issues.
> ---
> drivers/virtio/virtio_ring.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> index 8f9413acd4e2..7b960ce9a034 100644
> --- a/drivers/virtio/virtio_ring.c
> +++ b/drivers/virtio/virtio_ring.c
> @@ -2074,7 +2074,7 @@ static void *virtqueue_get_buf_ctx_packed_in_order(struct vring_virtqueue *vq,
> void **ctx)
> {
> unsigned int num = vq->packed.vring.num;
> - u16 last_used, id, last_used_idx;
> + u16 last_used, last_used_idx;
> bool used_wrap_counter;
> void *ret;
>
> @@ -2110,11 +2110,11 @@ static void *virtqueue_get_buf_ctx_packed_in_order(struct vring_virtqueue *vq,
> *len = vq->packed.desc_state[last_used].total_len;
>
> if (unlikely(last_used >= num)) {
> - BAD_RING(vq, "id %u out of range\n", id);
> + BAD_RING(vq, "id %u out of range\n", last_used);
> return NULL;
> }
> if (unlikely(!vq->packed.desc_state[last_used].data)) {
> - BAD_RING(vq, "id %u is not a head!\n", id);
> + BAD_RING(vq, "id %u is not a head!\n", last_used);
> return NULL;
> }
>
> --
> 2.39.5
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] virtio_ring: fix uninitialized used value
2025-07-25 13:11 ` Michael S. Tsirkin
@ 2025-07-28 3:29 ` Jason Wang
0 siblings, 0 replies; 3+ messages in thread
From: Jason Wang @ 2025-07-28 3:29 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: xuanzhuo, eperezma, virtualization, linux-kernel, Naresh Kamboju,
Randy Dunlap, kernelci . org bot, Linux Kernel Functional Testing
On Fri, Jul 25, 2025 at 9:12 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Fri, Jul 25, 2025 at 04:36:35PM +0800, Jason Wang wrote:
> > Buildbot reports uninitialized used:
> >
> > drivers/virtio/virtio_ring.c:2113:40: error: variable 'id' is
> > uninitialized when used here [-Werror,-Wuninitialized]
> > 2113 | BAD_RING(vq, "id %u out of range\n", id);
> > | ^~
> > drivers/virtio/virtio_ring.c:2077:19: note: initialize the variable
> > 'id' to silence this warning
> > 2077 | u16 last_used, id, last_used_idx;
> > | ^
> > | = 0
> > 1 error generated.
> >
> > Fixing this by use last_used instead and drop the complete unused
> > variable id.
> >
> > Cc: Naresh Kamboju <naresh.kamboju@linaro.org>
> > Cc: Randy Dunlap <rdunlap@infradead.org>
> > Reported-by: kernelci.org bot <bot@kernelci.org>
> > Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
>
> I squashed but I think you should respin.
> also noticed a couple of minor issues.
>
I think a reppin of this patch should be sufficient.
I can post a new version.
Thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-07-28 3:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-25 8:36 [PATCH] virtio_ring: fix uninitialized used value Jason Wang
2025-07-25 13:11 ` Michael S. Tsirkin
2025-07-28 3:29 ` Jason Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).