[PATCH] virtio: fix variable shadowing in virtqueue_add_sgs input scatter loop

Ahmad Fatoum a.fatoum at pengutronix.de
Sun Feb 15 09:11:23 PST 2026


The inner for loop in the in_sgs processing section had a local
declaration 'struct scatterlist *sg = sgs[n]' that shadowed the loop
variable 'sg' from the enclosing for statement.

Remove the shadowing declaration so the loop variable is used
consistently, matching the out_sgs loop.
This aligns the loop with the logic above for out_sgs.

Reported-by: Claude Opus 4.6 <noreply at anthropic.com>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 drivers/virtio/virtio_ring.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 2c61329414d9..55f6be311c51 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -112,7 +112,6 @@ int virtqueue_add_sgs(struct virtqueue *vq, struct scatterlist *sgs[],
 
 	for (; n < (out_sgs + in_sgs); n++) {
 		for (sg = sgs[n]; sg; sg = sg_next(sg)) {
-			struct scatterlist *sg = sgs[n];
 			dma_addr_t addr = vring_map_one_sg(vq, sg, DMA_FROM_DEVICE);
 			if (vring_mapping_error(vq, addr))
 				goto unmap_release;
-- 
2.47.3




More information about the barebox mailing list