Skip to content

Commit 45ebc7e

Browse files
vivierPaolo Abeni
authored andcommitted
virtio_ring: Fix error reporting in virtqueue_resize
The virtqueue_resize() function was not correctly propagating error codes from its internal resize helper functions, specifically virtqueue_resize_packet() and virtqueue_resize_split(). If these helpers returned an error, but the subsequent call to virtqueue_enable_after_reset() succeeded, the original error from the resize operation would be masked. Consequently, virtqueue_resize() could incorrectly report success to its caller despite an underlying resize failure. This change restores the original code behavior: if (vdev->config->enable_vq_after_reset(_vq)) return -EBUSY; return err; Fix: commit ad48d53 ("virtio_ring: separate the logic of reset/enable from virtqueue_resize") Cc: xuanzhuo@linux.alibaba.com Signed-off-by: Laurent Vivier <lvivier@redhat.com> Acked-by: Jason Wang <jasowang@redhat.com> Link: https://patch.msgid.link/20250521092236.661410-2-lvivier@redhat.com Tested-by: Lei Yang <leiyang@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 5177373 commit 45ebc7e

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

drivers/virtio/virtio_ring.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2797,7 +2797,7 @@ int virtqueue_resize(struct virtqueue *_vq, u32 num,
27972797
void (*recycle_done)(struct virtqueue *vq))
27982798
{
27992799
struct vring_virtqueue *vq = to_vvq(_vq);
2800-
int err;
2800+
int err, err_reset;
28012801

28022802
if (num > vq->vq.num_max)
28032803
return -E2BIG;
@@ -2819,7 +2819,11 @@ int virtqueue_resize(struct virtqueue *_vq, u32 num,
28192819
else
28202820
err = virtqueue_resize_split(_vq, num);
28212821

2822-
return virtqueue_enable_after_reset(_vq);
2822+
err_reset = virtqueue_enable_after_reset(_vq);
2823+
if (err_reset)
2824+
return err_reset;
2825+
2826+
return err;
28232827
}
28242828
EXPORT_SYMBOL_GPL(virtqueue_resize);
28252829

0 commit comments

Comments
 (0)