Skip to content

Commit b4ba120

Browse files
jasowangmstsirkin
authored andcommitted
vhost: fail early when __vhost_add_used() fails
This patch fails vhost_add_used_n() early when __vhost_add_used() fails to make sure used idx is not updated with stale used ring information. Reported-by: Eugenio Pérez <eperezma@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com> Message-Id: <20250714084755.11921-2-jasowang@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Tested-by: Lei Yang <leiyang@redhat.com>
1 parent 7d9896e commit b4ba120

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/vhost/vhost.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2983,6 +2983,9 @@ int vhost_add_used_n(struct vhost_virtqueue *vq, struct vring_used_elem *heads,
29832983
}
29842984
r = __vhost_add_used_n(vq, heads, count);
29852985

2986+
if (r < 0)
2987+
return r;
2988+
29862989
/* Make sure buffer is written before we update index. */
29872990
smp_wmb();
29882991
if (vhost_put_used_idx(vq)) {

0 commit comments

Comments
 (0)