Skip to content

Commit 5fb5bd7

Browse files
committed
virtio_ring: Fix error reporting in virtqueue_resize
JIRA: https://issues.redhat.com/browse/RHEL-84199 Upstream Status: git@gitlab.com:redhat/centos-stream/src/kernel/centos-stream-9.git commit 45ebc7e Author: Laurent Vivier <lvivier@redhat.com> Date: Wed May 21 11:22:34 2025 +0200 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> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
1 parent 134517e commit 5fb5bd7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/virtio/virtio_ring.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2724,7 +2724,7 @@ int virtqueue_resize(struct virtqueue *_vq, u32 num,
27242724
void (*recycle)(struct virtqueue *vq, void *buf))
27252725
{
27262726
struct vring_virtqueue *vq = to_vvq(_vq);
2727-
int err;
2727+
int err, err_reset;
27282728

27292729
if (num > vq->vq.num_max)
27302730
return -E2BIG;
@@ -2744,7 +2744,11 @@ int virtqueue_resize(struct virtqueue *_vq, u32 num,
27442744
else
27452745
err = virtqueue_resize_split(_vq, num);
27462746

2747-
return virtqueue_enable_after_reset(_vq);
2747+
err_reset = virtqueue_enable_after_reset(_vq);
2748+
if (err_reset)
2749+
return err_reset;
2750+
2751+
return err;
27482752
}
27492753
EXPORT_SYMBOL_GPL(virtqueue_resize);
27502754

0 commit comments

Comments
 (0)