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 <[email protected]> Signed-off-by: Jason Wang <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Tested-by: Lei Yang <[email protected]>
1 parent 7d9896e commit b4ba120

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

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)