]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
virtio_ring: Fix error reporting in virtqueue_resize
authorLaurent Vivier <lvivier@redhat.com>
Wed, 21 May 2025 09:22:34 +0000 (11:22 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 3 Jul 2025 09:40:02 +0000 (11:40 +0200)
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 ad48d53b5b3f ("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>
drivers/virtio/virtio_ring.c

index b784aab66867031baadb6eab4e29a04d526b1946..4397392bfef000ac690563afc50d381dec2c374c 100644 (file)
@@ -2797,7 +2797,7 @@ int virtqueue_resize(struct virtqueue *_vq, u32 num,
                     void (*recycle_done)(struct virtqueue *vq))
 {
        struct vring_virtqueue *vq = to_vvq(_vq);
-       int err;
+       int err, err_reset;
 
        if (num > vq->vq.num_max)
                return -E2BIG;
@@ -2819,7 +2819,11 @@ int virtqueue_resize(struct virtqueue *_vq, u32 num,
        else
                err = virtqueue_resize_split(_vq, num);
 
-       return virtqueue_enable_after_reset(_vq);
+       err_reset = virtqueue_enable_after_reset(_vq);
+       if (err_reset)
+               return err_reset;
+
+       return err;
 }
 EXPORT_SYMBOL_GPL(virtqueue_resize);