When enabling the XSK pool, the header DMA address is mapped against
the send queue's virtqueue (sq->vq). However, the error handling path
incorrectly attempts to unmap it against the receive queue's virtqueue
(rq->vq).

Ensure the unmap operation uses the same virtqueue used for mapping to
maintain DMA API consistency.

Fixes: 21a4e3ce6dc7 ("virtio_net: xsk: bind/unbind xsk for tx")
Signed-off-by: Xuan Zhuo <[email protected]>
---
 drivers/net/virtio_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 72d6a9c6a5a2..7c6f304b7be5 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -5917,7 +5917,7 @@ static int virtnet_xsk_pool_enable(struct net_device *dev,
 err_rq:
        xsk_pool_dma_unmap(pool, 0);
 err_xsk_map:
-       virtqueue_unmap_single_attrs(rq->vq, hdr_dma, vi->hdr_len,
+       virtqueue_unmap_single_attrs(sq->vq, hdr_dma, vi->hdr_len,
                                     DMA_TO_DEVICE, 0);
 err_free_buffs:
        kvfree(rq->xsk_buffs);
-- 
2.32.0.3.g01195cf9f


Reply via email to